Python? Please Explain?


#1

x = 5
if 8 % 4:
x = x - 1
elif 3 < 4 / 2:
x = x - 2
elif “t”:
x = x - 3
else:
x = x - 4
print (x)
Output = 2
How, I really do not understand it!


#2
8 % 4        # 0 -> falsy => False

3 < 4 / 2    #            => False

"t"          # => truthy  => True

so, 5 - 3 is 2.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.