FINAL Large GOYO: Number Guesser (Exam Practice)

What are/were your feelings about this project?

I am very proud of my work and final result as it can be played in many different forms and has a lot of features to embrace. The project was starting out to be a practice for the exam that wouldn’t take very long. I feel I went the extra mile, I made 4 gamemodes, implemented statistics, the ability to play multiple times without restarting the code, and made it user-friendly.

How did you plan for this project?  Did you use the plan once you started?

I planned solely to have a 1-100 gamemode, but that was it, I obviously did not keep that same plan as I continued. I used every Python method I could think of.

What did you like or learn during this project? (positive and not)

I learned the difference between integers and floats, which came in handy for my statistics. I also learned how to restart a whole sequence in a program using loops and if-then statements. I liked everything

Will this project change your work or life in any way?  How?

It will definitely change my leaderboard status in gnimmargorp. However, jokes aside, I think it is a sign of how much I’ve improved over this year, and I feel like I’m even more confident to pursue some deeper and more challenging Python projects.

How will you use this project in your life?  Who might you share this with?

I’ve already shared it with friends who try to get the best win streak, which I think is interesting. I’ve made something that has competitive value, something I had always wanted to accomplish. Then again, it really isn’t much more than that, a game.

Link what you did.

import random
#INSTRUCTIONS/INFO
print "Welcome To Number Guesser (by Titus Oldham)"
print "Select your mode based off of your gameplay preference."
print "In Easy, you have 3 tries to guess a number between 1 and 10."
print "In Medium, you have 6 tries to guess a number between 1 and 100."
print "In Hard, you have 10 tries to guess a number between 1 and 1000."
print "In Extreme, you have 15 tries to guess a number between 1 and 1000, but with a twist."
print "By guessing a number, you will be told where in relation you are to the actual one."
print "Good Luck!"
print "\n"

#Statistics Storage
wins = 0
losses = 0
streak = 0

while True:
    #Mode Selection
    a = raw_input("Select: Easy, Medium, Hard, Extreme: ")
    a = a.lower()
    #Easy Mode Gameplay
    if a == "easy": #Conditional
        b = random.randrange(1,11)
        for blank in range(1,4): #Loop
            c = raw_input("Guess Number " + str(blank) + ": ") 
            if int(c) == b:
                print "You Win!"
                wins = wins + 1
                streak = streak + 1 
                break
            elif int(c) > b:
                print "Too High"
                if blank == 3:
                    print "Game Over Number Was " + str(b)
                    losses = losses + 1
                    streak = 0
            elif int(c) < b:
                print "Too Low"
                if blank == 3:
                    print "Game Over, Number Was " + str(b)
                    losses = losses + 1
                    streak = 0
    #Medium Mode Gameplay
    elif a == "medium":
        b = random.randrange(1,101)
        for blank in range(1,7):
            c = raw_input("Guess Number " + str(blank) + ": ")
            if int(c) == b:
                print "You Win!"
                wins = wins + 1
                streak = streak + 1 
                break
            elif int(c) > b:
                print "Too High"
                if blank == 6:
                    print "Game Over Number Was " + str(b)
                    losses = losses + 1
                    streak = 0
            elif int(c) < b:
                print "Too Low"
                if blank == 6:
                    print "Game Over, Number Was " + str(b)
                    losses = losses + 1
                    streak = 0
    #Hard Mode Gameplay
    elif a == "hard":
        b = random.randrange(1,1001)
        for blank in range(1,11):
            c = raw_input("Guess Number " + str(blank) + ": ")
            if int(c) == b:
                print "You Win!"
                wins = wins + 1
                streak = streak + 1 
                break
            elif int(c) > b:
                print "Too High"
                if blank == 10:
                    print "Game Over Number Was " + str(b)
                    losses = losses + 1
                    streak = 0
            elif int(c) < b:
                print "Too Low"
                if blank == 10:
                    print "Game Over, Number Was " + str(b)
                    losses = losses + 1
                    streak = 0
    #Extreme Mode Gameplay
    elif a == "extreme":
        b = random.randrange(1,1001)
        print "Info:" #Info/Instruction pt. 2
        print "Warm means the number is in the 100 digit range."
        print "Hot means the number is in the 50 digit range."
        print "INFERNO means the number is in the 10 digit range."
        for blank in range(1,16):
            c = raw_input("Guess Number " + str(blank) + ": ")
            if int(c) == b:
                print "You Win!"
                wins = wins + 1
                streak = streak + 1 
                break
            elif int(c) in range(b-5,b+5):
                print "INFERNO"
                if blank == 15:
                    print "Game Over Number Was " + str(b)
                    losses = losses + 1
                    streak = 0
            elif int(c) in range(b-25,b+25):
                print "Hot"
                if blank == 15:
                    print "Game Over Number Was " + str(b)
                    losses = losses + 1
                    streak = 0
            elif int(c) in range(b-50,b+50):
                print "Warm"
                if blank == 15:
                    print "Game Over Number Was " + str(b)
                    losses = losses + 1
                    streak = 0
            else:
                print "cold..."
                if blank == 15:
                    print "Game Over Number Was " + str(b)
                    losses = losses + 1
                    streak = 0

    else:
        print "Error: Restart Program"
        break
    print "\n"

    #Statistics Reminder
    print "Session Stats:"
    print "Wins: " + str(wins)
    print "Losses: " + str(losses)
    if losses > 0:
        print "W/L Ratio: " + str(float(wins)/losses)
    if streak >= 2:
        print "You Are On A " + str(streak) + " Game Streak!"
    print "\n"
    
    pa = raw_input("Would You Like To Play Again? y/n: ")
    if pa != "y":
        break
    

Resources (both from stackoverflow, my savior this school year):

Restarting program based upon user input

Difference between integer and float

Other than these, I could accomplish the program based off of experience and memory.

One thought on “FINAL Large GOYO: Number Guesser (Exam Practice)”

Leave a Reply

Your email address will not be published. Required fields are marked *