大家好,又见面了,我是你们的朋友全栈君。
How to tell Python to make intelligent decisions about what code to run, what code to skip, and what code to repeat based on the values it has.With Flowcharts!
more sources:[Python Control Flow Statements and Loops]/
More Control Flow Tools
Flow control will need yes or no options to make decisions.In Python code,yes and no is shown as Boolean Values True and False.1.Boolean Values can be stored in variables and use as expressions.
Comparison Operators also called relational operators as below:
Equal to ==
Not equal to !=
Less than <
Greater than >
Less than or equal to <=
Greater than or equal to >=
When use comparison operators,an integer or floating-point value will always be unequal to a string value.That means 31!= ‘31’.Also The <, >, <=, and >=operators, on the other hand, work only with integer and floating-point values.Numbers! Never with string value.Computer will confuse if you did.
Don’t confuse with one equal side or two equal sides.
Two equal sides (equal to) asks whether 2 valus are the same with each other.(eg. True == True)
While one equal side is about puts value to the left side as variable. (Box in eg. Age = 7 )
The three Boolean operators are and, or, and not.
and,or always with 2 boolean values(experssions),considered as binary operators.
not only with one boolean value(experssion),considered as unary operator.
Python evaluates the not operators first, then the and operators, and then the or operators.
Flow control elements like conditions (like boolean values or expressions),blocks of code,program execution,flow control statements.(eg.if …: end with colon.or else:elif: while and for loops statement,continue and break statement.)
There are 3 rules of blocks of code:
Blocks begin when the indentation increases.
Blocks can contain other blocks.
Blocks end when the indentation decreases to zero or to a containing
block’s indentation.
Only use continue and break statements inside while and for loops.
For loops example as for i in range(3):
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/139580.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...