If statement applied--Maximum value
1 """2 find the maximum value in three digits and print it out3 """4a = Int (input ("A:"))5b = Int (input ("B:"))6c = Int (input ("C:"))7 8 ifA>B:9Max_num =aTen ifMax_num >C: One Print(max_num) A Else: - Print(c) - Else: theMax_num =b - ifMax_num >C: - Print(max_num) - Else: + Print(c) - + Print(Max (A,B,C))#built-in functions A Print(min (a,b,c))#built-in functions
While Loop
Example 1: Output an even number between 1 and 100 (but I think my program is so stupid)
1 """2 an even number between 1 and 100 outputs3 """4A =05 whileA < 101:6 forIinchRange (101):7 ifi%2 = =0:8 Print. IO9i + = 1Ten ifI > 100: One Break A
Simplified:
A = while a < 101: if a%2 = = 0 :print(a) + = 1
Note: When the conditional judgment statement, must be in the program to do flase interrupt, or will continue to run indefinitely
Re-learning Python-day 02-python Foundation, if statement application + while loop application