Guest User

Untitled

a guest
Jan 23rd, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. #GuessingGame.py
  2. #import random module
  3. #generate random number from 1-10
  4. #store the number in a variable, which will be the secrete number
  5. #ask user to guess number from 1-10
  6. #use a while to compare the secret number to the user's number
  7. # as long as the user's guess is not equal to the secret number kee checkigng
  8. #let the user know that they have guess the number, then quit
  9. #tell user guess is too low or too high
  10.  
  11.  
  12. import random
  13. n = random.randint (1,10)
  14. guess = int(input("enter a number from 1 to 10"))
  15. while n != "guess":
  16. print
  17. if guess > n:
  18. print("guess is too high")
  19. guess = int(input("enter a number from 1 to 10"))
  20. elif guess < n:
  21. print("guess is too low")
  22. guess = int(input("enter a number from 1 to 10"))
  23. else:
  24. print("you have guessed the correct number!")
  25. break
Add Comment
Please, Sign In to add comment