Mar-20-2021, 06:00 AM
You want to play "guess the number"?
Copy and paste this into your Python shell, then write: myApp() in the shell
Copy and paste this into your Python shell, then write: myApp() in the shell
def myApp(): import random print('What shall the maximum number be?') maxNum = int(input('Enter the maximum number ... ')) hads= random.randint(1,maxNum) my_guess = int(input('Enter a number to guess the number "hads" ... ')) if my_guess == hads: print("You guessed the number first time!! You are a psychic!!") print('Your guess was:', my_guess) exit elif my_guess != hads: print('Wrong! Try again!') while my_guess != hads: my_guess = int(input('Enter a number ... ')) if my_guess == hads: print("You guessed the number!! Byebye!") print(my_guess) elif my_guess > hads: print('You guessed too high!') elif my_guess < hads: print('You guessed too low!')