Tag: python If condition judgment
# Condition Judgment # 1print ("#1") age = 20if age >= 18: print (' Your age is ', age) print (' adult ') print ("---------------------") # 2print ("#2") age = 3if age >= 18: print (' your age Is ', age) print (' adult ') else: print (' Your age is ') , age) print (' teenager ') print ("---------------------") # 3print ("#3") age = 3if age >= 18: print (' adult ') Elif age >= 6: print (' teenager ') else: print (' Kid ') print ("--------------------- ") # 4print (" #4 ") s = input (' birth: ') # input The data type returned is STR, which cannot be compared directly to an integer, with an int () strong to # Of course, if you enter a non-numeric such as ' abc ', you need to catch the error of the program runtime, and no discussion birth = int (s) if birth < 2000: print (' 00 ago ') Else: print (' 00 after ') print ("---------------------")
Conditional judgment in Python