python basis - flow control statements

if conditions: 
    the condition code execution 
elif condition: 
    the above condition is not satisfied and left the 
elif condition: 
    the above condition is not satisfied and left the 
elif condition: 
    the above condition is not satisfied and left this     
else: 
    all of the above conditions are not satisfied and left this
= 23 age_Lao 
age_Lao_chun = int (the INPUT ( "Guess my age:")) #input import user input
IF age_Lao_chun == age_Lao:
Print ( "Congratulations, you guessed it")
elif age_Lao_chun> age_Lao:
Print ( "to the small Well guess a little ")
elif age_Lao_chun <age_Lao:
Print (" to guess a little big thing ")


score = int (input ( "Enter score:")) 
IF Score> = 100:
Print ( "A")
elif Score> = 90:
Print ( "B")
elif Score> = 80:
Print ( "C")
the else:
Print ( "the end of the course")


password encryption module
import getpass          #getpass 密码密文
username=input("username:")
password=getpass.getpass("password:")
print(username,password)
 
while loop
= 23 age_Lao 
COUNT = 0
the while COUNT <3: # judge wrong three times, that
age_Lao_Chun = int (input ( "Please enter my age:"))
IF age_Lao_Chun == age_Lao:
Print ( "hello clever ah")
break # guessed it exits the loop
elif age_Lao_Chun> age_Lao:
Print ( "guess a little small thing")
the else:
Print ( "guess bigger thing")
count + = 1 # and above to make a judgment count

One to one hundred and then click Print
number=1
while number<101:
print(number)
number+=1

0 = Number 
the while Number <10:
Number + =. 1
IF Number == 7: == # 7 determines Number
Continue == # 7 if the loop is executed on the next cycle out
print (number)

The total number of one to one hundred
= 0 number_sum 
Number. 1 =
the while Number <101:
number_sum + = Number
Number + =. 1
Print (number_sum)


one to one hundred even
=. 1 NUMBER_1 
the while NUMBER_1 <= 100:
IF NUMBER_1% 2 == 0:
Print (NUMBER_1)
NUMBER_1 +. 1 =


odd number of one to one hundred
=. 1 NUMBER_1 
the while NUMBER_1 <= 100:
! IF NUMBER_1% 2 = 0: # 2! It is divided by 2 = 0 not to
Print (NUMBER_1)
NUMBER_1 +. 1 =






Guess you like

Origin www.cnblogs.com/laochun/p/11204421.html