Analyzing python branch statement equivalent logical operators

# Branch statement 
Age = 233
IF Age <18:
Print ( 'You are under 18 years of age, No Entry')
elif Age> 18 and Age <60:
Print ( "Welcome, between the ages of 18-60")
the else :
Print ( "Welcome, older than 60 years old")

weight = the INPUT ( 'body weight (kg):')
height = the INPUT ( "height (cm):")
# weight / height squared pow (4,2) = 16
BMI = int (weight) / POW (a float (height), 2)
Print (BMI)

IF BMI <= 18.4:
Print ( 'slim')
elif BMI> 18.4 and BMI <= 23.9:
Print ( 'normal')
BMI elif> 23.9 and BMI <= 27.9:
Print ( 'heavy')
the else:
Print ( 'fat')



# Analyzing equivalent
Print (== 1.0. 1) #True
Print (. 1 == '. 1') #False
Print (== int. 1 ( '. 1')) #True

# priority logical operators not> and> or
a = 4 > 1 #True
b = 5 < 2 #False
c = 8 == 8 #True
d = 9 < 6 #False

print( a and b) #False
print( a and c) #True
print( a or b) #True
print( d or b) #False
print(not a) #False
print(not b) #True

r1 = a and b or c and not d
# a and b or c and True
# False or True
# True
print(r1) # True

r2 = (a and (not b or c)) and d
# (a and (True or c)) and d
# (a and True) and d
# True and False
# False
print(r2) # False

Guess you like

Origin www.cnblogs.com/ericblog1992/p/11269486.html