Hi. I've been using free online resources the past few days to learn Python and I was practicing what I had learned so far when I wrote this program, mainly focusing on functions though. There are many things I would do differently if I were to go back over it but this is what I came up with in probably an hour or so of creating my random idea. What am doing that I should do differently? Criticism is appreciated
I didn't use any sort of loops because I'm not that fluent yet and would've had to reference something and I just wanted to do what I could, plus I made it do what I wanted it to do without.
I also realize instead of using print then asking for input I could put input('text here').
I didn't use any sort of loops because I'm not that fluent yet and would've had to reference something and I just wanted to do what I could, plus I made it do what I wanted it to do without.
I also realize instead of using print then asking for input I could put input('text here').
import time import random gameList = ['Guess the Number',''] taskList = ['Play a Game?','Hear a joke?','Have your mind blown?'] #lightJoke = ['','','','','',''] darkJoke = ['What is red and bad for your teeth? A brick.'] mindBlow = ['The surface area of Russia is slightly larger than that of the surface area of Pluto.','Anne Frank and Martin Luther King Jr. were born in the same year.'] def wutNow(): print('What would you like me to do now?') print(taskList) chosenTask = input().lower() if chosenTask == 'play a game' or chosenTask == 'game' or chosenTask == 'play': listGames() elif chosenTask == 'joke' or chosenTask == 'hear a joke' or chosenTask == 'hear' or chosenTask == 'tell jokes': tellJoke() elif chosenTask == 'have my mind blown' or chosenTask == 'mind blown' or chosenTask == 'have your mind blown': blowMind() def intro(): print('Nice to meet you ' + name + ',here is a list of things I can do.') thingsIcanDo = ['List Games','Tell Jokes','Blow your mind'] print(thingsIcanDo) time.sleep(1) print('What would you like me to do?') choice = input().lower() if choice == 'game' or choice == 'play a game' or choice == 'play': print('Which game would you like to play?') print(gameList) chosenGame = input().lower() if chosenGame == 'guess' or chosenGame == 'guess the number': print("Great choice! Let's play!") guessGame() elif choice == 'tell a joke' or choice == 'tell' or choice == 'joke' or choice == 'hear a joke' or choice == 'tell jokes': tellJoke() elif choice == 'blow your mind' or choice == 'blow my mind' or choice == 'blow mind': blowMind() #Function to list games and take fokn input def listGames(): print(gameList) print('Which game would you like to play ' + name + '?') gme = input().lower() if gme == 'guess the number' or gme == 'guess' or gme == 'number': guessGame() def afterGame(): print('Great game, would you like to play again?') answer = input().lower() if answer == 'y' or answer == 'yes': guessGame() elif answer == 'n' or answer == 'no': wutNow() def tellJoke(): print(random.choice(darkJoke)) input() print('Would you like to hear another joke?') again = input() if again == 'y' or again == 'yes': tellJoke() else: wutNow() def blowMind(): print(random.choice(mindBlow)) input() print('Would you like to have your mind blown again?') mBlow = input().lower() if mBlow == 'y' or mBlow == 'yes': blowMind() else: wutNow() #Guessing game function def guessGame(): print('I am thinking of a number between 1 and 100 ' + name + '.') guesses = 0 num = random.randint(1,100) for guesses in range(6): print('Take a guess.') guess = input() guess = int(guess) if guess < num: print('Too low!') if guess > num: print('Too high!') if guess == num: break if guess == num: guesses = str(guesses + 1) print('Great job! You guessed the number in '+ guesses + ' guesses.' ) if guess != num: num = str(num) print('Nope! My number was ' + num + ',maybe next time!') afterGame() print('Hello, my name is Monty, what is yours?') name = input() intro()