Quote of AWESOMENESS: “Creativity is intelligence having fun” ~ Albert Einstein
Hey, guys!
Back again with another python program.
Awesome isn’t?
Now, this program is an “advanced” version of a guessing number game. So basically, the program gives the user three guesses and the numbers are ranging from 1-10. Through each time the user types in the answer and is wrong, the input would spit out either “too high” or “too low” indicating what the user’s next move should be.
Mix around with it and experiment like maybe adding a wider range of numbers to guess from or maybe adding riddles to guess the number. This code is somewhat the basis of what else can be built with it, so be creative and have fun!
Here’s the code:
import random
range = random.randint(1, 10)
user_guess = 0
guess_counter = 0
print(“This is a guessing game and you will be given three tries to win! \nThe range will be between 1 and 10. \nGood luck!!”)
while guess_counter < 3:
user_guess = input(“What’s your guess?”)
guess_counter += 1
if user_guess.isnumeric():
user_guess = int(user_guess)
if user_guess < range:
print(“too low”)
elif user_guess > range:
print(“too high”)
else:
break
else:
print(“Not a number!”)
if user_guess == range:
print(“Awesome! You won!!”)
else:
print(“The number was actually”, range)
print(“Try again!”)
Have an awesome weekend!
Yours truly,
L.O.A.S.H
© Elizabeth Anne Villoria