import random # Random number module
num=random.randint(1,100) # Pick an integer at random for us to use
print(f' Tips : The correct number is {num}')
print('*'*30,' Guess number games ','*'*30)
print(' The rules of the game : If you guess right, you'll get 100 million dollars , Guess the range 1-100 Between , Please start !')
a=3 # Conditions for ending the cycle , Three opportunities
while a>0:
a-=1
number=int(input(' Please enter the number you want to guess :'))
if number<0 or number>100:
print(f' The number you entered is not within the specified range , You have {a} Second chance ')
elif number<num:
print(f' Your guess is small , You have {a} Second chance ')
elif number>num:
print(f' Your guess is too big , You have {a} Second chance ')
else:
print(' Congratulations on your guesses , Reward 1 Billion dollars !!!')
print(' Game over ')
break
if a==0: # Add another if Sentence judgment , Used to reset the number of times
print(' The opportunity has run out , Want to play again ')
key=input(' Please enter q Enter refresh times , Or enter another to end the game :')
if key =='q':
a=3
else:
print(f' The number of times has been used up , Challenge failure indication ! Tips : The correct number is {num}, Do it all over again !')
break