Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #week 2 to assignment
- import random
- chance = 5
- computer_input = random.randint(1, 20)
- point = 0
- while chance >0:
- user_input = int(input('Enter any numbers from 1 to 20: '))
- if user_input < 0 & user_input > 20:
- chance -= 1
- diff = user_input - computer_input
- #converting the ouput of difference between user_input - computer_input
- if(diff < 0 ):
- result = (-(diff))
- else:
- result = diff
- if user_input == computer_input:
- print ('Congratulations! You have won price.')
- if chance == 5:
- point +=50
- elif chance == 4:
- point +=40
- elif chance == 3:
- point +=30
- elif chance ==2:
- point += 20
- elif chance ==1:
- point +=10
- else:
- point = 0
- elif result <= 3:
- print ('You are almost near')
- elif result <=5:
- print ('You are near')
- else:
- print('Try again')
- chance = chance - 1
- print(f"you have {chance} chance ")
- print(f" Your point is {point} ")
Add Comment
Please, Sign In to add comment