## Read Dataset from excel file

0 likes • Oct 7, 2022
Python

## More Python Posts

```from functools import partial
```def sum_of_powers(end, power = 2, start = 1):  return sum([(i) ** power for i in range(start, end + 1)])
`""" Number Guessing Game----------------------------------------"""import randomattempts_list = []def show_score():    if len(attempts_list) <= 0:        print("There is currently no high score, it's yours for the taking!")    else:        print("The current high score is {} attempts".format(min(attempts_list)))def start_game():    random_number = int(random.randint(1, 10))    print("Hello traveler! Welcome to the game of guesses!")    player_name = input("What is your name? ")    wanna_play = input("Hi, {}, would you like to play the guessing game? (Enter Yes/No) ".format(player_name))    // Where the show_score function USED to be    attempts = 0    show_score()    while wanna_play.lower() == "yes":        try:            guess = input("Pick a number between 1 and 10 ")            if int(guess) < 1 or int(guess) > 10:                raise ValueError("Please guess a number within the given range")            if int(guess) == random_number:                print("Nice! You got it!")                attempts += 1                attempts_list.append(attempts)                print("It took you {} attempts".format(attempts))                play_again = input("Would you like to play again? (Enter Yes/No) ")                attempts = 0                show_score()                random_number = int(random.randint(1, 10))                if play_again.lower() == "no":                    print("That's cool, have a good one!")                    break            elif int(guess) > random_number:                print("It's lower")                attempts += 1            elif int(guess) < random_number:                print("It's higher")                attempts += 1        except ValueError as err:            print("Oh no!, that is not a valid value. Try again...")            print("({})".format(err))    else:        print("That's cool, have a good one!")if __name__ == '__main__':    start_game()`
`x[cat_var].isnull().sum().sort_values(ascending=False)`
`#Python 3: Fibonacci series up to ndef fib(n): a, b = 0, 1 while a < n:     print(a, end=' ')     a, b = b, a+b print()fib(1000)`
`""" Currency Converter----------------------------------------"""import urllib.requestimport jsondef currency_converter(currency_from, currency_to, currency_input):    yql_base_url = "https://query.yahooapis.com/v1/public/yql"    yql_query = 'select%20*%20from%20yahoo.finance.xchange%20where%20pair' \                '%20in%20("'+currency_from+currency_to+'")'    yql_query_url = yql_base_url + "?q=" + yql_query + "&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys"    try:        yql_response = urllib.request.urlopen(yql_query_url)        try:            json_string = str(yql_response.read())            json_string = json_string[2:            json_string = json_string[:-1]            print(json_string)            yql_json = json.loads(json_string)            last_rate = yql_json['query']['results']['rate']['Rate']            currency_output = currency_input * float(last_rate)            return currency_output        except (ValueError, KeyError, TypeError):            print(yql_query_url)            return "JSON format error"    except IOError as e:        print(str(e))currency_input = 1#currency codes : http://en.wikipedia.org/wiki/ISO_4217currency_from = "USD"currency_to = "TRY"rate = currency_converter(currency_from, currency_to, currency_input)print(rate)`