First, the input three random numbers, and determines a maximum value
Print ( " It is a maximum par applet parameter " ) number1 = INPUT ( ' Enter parameters. 1: ' ) number2 = INPUT ( ' enter the argument 2: ' ) number3 = INPUT ( ' enter 3 parameters: ' ) MAX_NUM = 0 IF number1> number2: MAX_NUM = number1 IF MAX_NUM> number3: Print ( ' maximum number is: ' + MAX_NUM) the else : Print ( ' maximum number is: ' + number3) the else : MAX_NUM = number2 IF MAX_NUM > number3: Print ( 'The maximum number is: '+ MAX_NUM) the else : Print ( ' maximum number is: '+ number3)
Second, a simulated account login, an error could not land three times and exit the program
1 = A
# initialize password
password = ' 123456 ' S = True # cycle begins the while S: mima = the INPUT ( " Please enter your password: " ) # password is correct, out of the loop IF password == mima: Print ( " the password is correct, welcome landing " ) S = False # 3 cycles, terminate the program elif A == 3 : Print ( " error number reaches three times, interrupted landing " ) bREAK # password is wrong, continue to cycle the else : Print ( " wrong password, please re-enter " ). 1 A + A = the else: Print ( " Welcome ")
1 user = 'CatdeXin'
2 passwd = 'abc123' 3 4 counter = 0 5 while counter < 3: 6 username = input('username: ') 7 password = input('password: ') 8 9 if username == user and password == passwd: 10 print("welcome %s login..."% user) 11 passwd_authentication = True 12 break 13 else: 14 print("Invalid username or password !") 15 16 counter += 1 17 if counter == 3: 18 keep_going_choice = str.title(input("Do you try to start again?【Y/N】")) 19 if keep_going_choice == 'Y': 20 counter = 0 21 22 else: print("Invalid username or password !")
Third, enter 99 multiplication table
x = 1
while y < 10:
#print(str(x)+'*'+str(x)+'=',x*x)
y = 1
while y <= x: print(y,'*',x,'=',y*x,end="\t") y += 1 print() x+=1