Logical Communication Python - conditional

a = 5

if a <6: # Condition 1 print (1) elif a <7: # Condition 2 print (2) else: print (3)

determining if the condition determination elif then determines the last else

  • Analyzing way: if

After the colon, the next command line, the condition code is determined colon : after the front row of the next content, few cells will empty

Space school called indentation , such as writing articles we have two empty cells, which is called first line indent, Python, the colon and indentation is a syntax [Note: indentation is four spaces or a Tab key]

 Indented content (Print () function), and if condition code block composed of a (a whole), if conditions become under internal command
If you remove the indentation, and the print command IF conditions become two different code groups, are parallel relationship

If elif else between the three are mutually exclusive

 

  • if nested

Simply put, it is this: In the case of basic conditions are met, then additional conditional basis under the conditions.

 

Guess you like

Origin www.cnblogs.com/Dozeoff/p/11280512.html