Guest User

Untitled

a guest
Dec 13th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. #week 2 to assignment
  2.  
  3. import random
  4.  
  5. chance = 5
  6. computer_input = random.randint(1, 20)
  7. point = 0
  8. while chance >0:
  9. user_input = int(input('Enter any numbers from 1 to 20: '))
  10. if user_input < 0 & user_input > 20:
  11. chance -= 1
  12. diff = user_input - computer_input
  13.  
  14. #converting the ouput of difference between user_input - computer_input
  15. if(diff < 0 ):
  16. result = (-(diff))
  17. else:
  18. result = diff
  19.  
  20. if user_input == computer_input:
  21. print ('Congratulations! You have won price.')
  22. if chance == 5:
  23. point +=50
  24. elif chance == 4:
  25. point +=40
  26. elif chance == 3:
  27. point +=30
  28. elif chance ==2:
  29. point += 20
  30. elif chance ==1:
  31. point +=10
  32. else:
  33. point = 0
  34. elif result <= 3:
  35. print ('You are almost near')
  36. elif result <=5:
  37. print ('You are near')
  38. else:
  39. print('Try again')
  40.  
  41. chance = chance - 1
  42. print(f"you have {chance} chance ")
  43. print(f" Your point is {point} ")
Add Comment
Please, Sign In to add comment