Python Forum
Feedback on my first program?
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Feedback on my first program?
#1
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').
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()
Reply


Messages In This Thread
Feedback on my first program? - by jibby - Jun-12-2018, 04:20 AM
RE: Feedback on my first program? - by perfringo - Jun-12-2018, 06:35 AM
RE: Feedback on my first program? - by jibby - Jun-12-2018, 10:40 AM
RE: Feedback on my first program? - by killerrex - Jun-12-2018, 08:47 AM
RE: Feedback on my first program? - by perfringo - Jun-14-2018, 06:38 AM
RE: Feedback on my first program? - by jibby - Jun-18-2018, 04:09 AM
RE: Feedback on my first program? - by WolfWayfarer - Jul-16-2018, 08:42 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  First program feedback xyzabc12310000 2 3,452 May-20-2018, 05:06 PM
Last Post: xyzabc12310000
  I need some feedback on this program tannishpage 3 3,188 Mar-22-2018, 05:31 AM
Last Post: tannishpage

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020