Hi Everyone! Welcome to Cool Python Projects!
In this post I will be showing you how to make a Guess that Number Game in Python. Please remember to follow me to stay updated on any new projects.
import random
print("I have thought of a number between 1 and 10. But I will not tell you, you have to guess it.")
the_number = random.randint(1, 10)
username = input("What is your name? ")
if username == 'Abhinav Gupta':
print("Hello Abhinav Gupta, my name is Alexa.")
user_int = -1
while user_int != the_number:
user_input = input("Guess a number between 1 and 10. ")
user_int = int(user_input)
if user_int > the_number:
print('Oh No {0}, Your guess {1} is too high!'.format(username, user_int))
elif user_int < the_number:
print('Uh Oh, {0} Your guess {1} is to small!'.format(username, user_int))
else:
print("YOU GOT IT, WELL DONE!")
print("Well Done, take rest now.")
I hope you enjoyed this Python project.
Top comments (0)