Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #GuessingGame.py
- #import random module
- #generate random number from 1-10
- #store the number in a variable, which will be the secrete number
- #ask user to guess number from 1-10
- #use a while to compare the secret number to the user's number
- # as long as the user's guess is not equal to the secret number kee checkigng
- #let the user know that they have guess the number, then quit
- #tell user guess is too low or too high
- import random
- n = random.randint (1,10)
- guess = int(input("enter a number from 1 to 10"))
- while n != "guess":
- print
- if guess > n:
- print("guess is too high")
- guess = int(input("enter a number from 1 to 10"))
- elif guess < n:
- print("guess is too low")
- guess = int(input("enter a number from 1 to 10"))
- else:
- print("you have guessed the correct number!")
- break
Add Comment
Please, Sign In to add comment