Greater than
= greater than or equal to
< less than
<= less than or equal to
= = equals
! = Not equal to
Judgment statement
If condition:
Operation performed with Condition True (true)
Else
Action performed on condition False (false)
While condition:
Operation performed with Condition True (true)
temp = input ("Please enter a number:")
guess = Int (temp)
While guess! = 8:
temp = Inpur ("Guess wrong, please reenter a number:")
guess = = Int (temp)
if guess = = 8:
Print ("You are the one in my Heart")
Print ("Unfortunately no reward")
Else
If guess > 8:
Print ("Big, Big")
Else
Print ("Little Xiao Xiao")
Print ("Game Over")
Number of Cycles
temp = input ("Please enter a number:")
guess = Int (temp)
Err_time = 0
While Err_time < 3:
temp = input ("Wrong guessing, please reenter a number:")
guess = Int (temp)
if guess = = 8:
Print ("Are you the one in my heart?") ")
Print ("Guessing is useless")
Break
Else
If guess > 8:
Print ("Big, Big")
Else
Print ("Little Xiao Xiao")
Err_time+=1
Else
Print ("Try Too many times")
Print ("Game Over")
Random module
Return results after generating random numbers
Import Random
num = Random.randint (1,10)
guess = int (num)
Err_time = 0
While Err_time < 3:
num = input ("Please enter a number:")
guess = int (num)
if guess = = 8:
Print ("Are you the one in my heart?") ")
Print ("Guessing is useless")
Break
Else
If guess > 8:
Print ("Big, Big")
Else
Print ("Little Xiao Xiao")
Err_time+=1
Else
Print ("Try Too many times")
Print ("Game Over")
Improve Digital Games