Quote of AWESOMENESS: “Creativity is intelligence having fun” ~ Albert Einstein
Back again with another python program.
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:
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
user_guess = int(user_guess)
if user_guess < range:
elif user_guess > range:
print(“Not a number!”)
if user_guess == range:
print(“Awesome! You won!!”)
print(“The number was actually”, range)
Have an awesome weekend!
© Elizabeth Anne Villoria