Guest User

Untitled

a guest
Feb 24th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. #Xuan Wen
  2. #A01045836
  3.  
  4. import random
  5.  
  6. def user_input():
  7. user_input = int(input('Make a guess:'))
  8. return user_input
  9.  
  10. def right_answer():
  11. the_num = random.randint(1, 100)
  12. return the_num
  13.  
  14. def compare():
  15. count = 1
  16. input_num = user_input()
  17. answer = right_answer()
  18. while input_num != answer and count < 7:
  19. if input_num > 100 or input_num < 1:
  20. print('Too bad! The number chosen was', answer)
  21. break
  22. else:
  23. while count < 7:
  24. if input_num < answer:
  25. print('Too Low!!')
  26.  
  27. elif input_num > answer:
  28. print('Too high!!')
  29.  
  30. else:
  31. count = count + 1
  32. break
  33. count = count + 1
  34. input_num = user_input()
  35.  
  36. print('Run out of guesses. The number chosen was', answer)
  37.  
  38. if input_num == answer:
  39. print('Well done! You found the number in', count, 'times.')
  40.  
  41. def main():
  42. compare_num = compare()
  43.  
  44. main()
Add Comment
Please, Sign In to add comment