1. Guess the age, you can let the user guess up to three times!
1Print"---------welcome to guessing age game---------") # Print game title2 3Guess =3#准许猜测次数4 5Age = about# Age equals6 7 whileGuess >0: #循环执行8 9User_guess =int(input ("Enter the age you guessed:") # Enter a guess valueTen one print (type (USER_GUESS)) # printing input type a - ifUser_guess >age : # If it's larger than print below - thePrint"try the smaller ...") - - elifUser_guess <age : # if, if less than, print below - +Print"try the bigger ...") - + Else: # Otherwise print below a atPrint"you guessed it!") - -guess-=1#执行一次, the number of guesses is reduced once
2. Guess the age, every 3 times, ask him, also want to continue to play, y (continue), n (stop)
1Print"---------welcome to guessing the age and playing games---------") # Print game title2 3Age = about# Age equals4 5Guess =1#猜测次数默认值6 7 8 whileTrue: #循环为真执行9 ifGuess >3: #如果猜测大于3Tenpursue_carry_on = input ("do you want to keep guessing? y or n") one ifpursue_carry_on = ="y": #必须输入小写y aGuess =1 - Else: - break thePrint"the game is about to start you have a total of 3 opportunities, this is the first", guess,"Second Chance"# Indicates the number of console sessions - -User_guess =int(input ("Enter the age you guessed:")) # - + - ifUser_guess >age : # If it's larger than print below + aPrint"try the smaller ...") at - elifUser_guess <age : # if, if less than, print below - -Print"try the bigger ...") - - Else: # Otherwise print below in -Print"you guessed it!") to break + -Guess + =1#执行一次, the number of guesses added once
3, Write the login interface input user name password Authentication successful display welcome information three times after the wrong lock
Python on the first day a few small games