FLOW CONTROL

A\The differences between == and = operators:

1 the == operator(equal to) asks whether two values are the same as each other;

2 the = operator(assignment)puts the value on the right into the variable on the left. 

 

B\ Comparison Operator :  ==   !=  >  <  >=  <=

     Boolean Operator      : and  or  not

     Boolean Value: Ture False

 

C\Boolean operators have an order of operations:

   1 Math and comparison operators first;

   2 not first,then the and,or last; 

    e.g: not not True or False and not True     the result is True

 

D\Lines of python code can be grouped together in blocks.You can tell when a block begins and ends from the indentation of the lines of code:

   1 Blocks begin when the indentation increases;

   2 Blocks can contain other blocks;

   3 Blocks end when the indentaiton decreases to zero,or to a containing block's indentation;

 

 E\There are some values in other data types (not undefined variable) that conditions will consider equivalent to True and False.When used in conditons,0,0.0 and ' '(the empty string)are considerd False,while all other values are considered True.

  e.g   

1 name=''
2 while not name:
3     print('enter your name:')
4     name=input()
5 print('how many guests do you have?')
6 numofGuest=int(input())
7 if numofGuest:
8     print('make sure have enough room.')
9 print('Done!')

 

 

F\ if\while contains:  1\keyword (if,while)  2\condition(Boolean Expression) 3\colon  4\clause

           for contains:   1\for keyword 2\variable 3\in keyword 4\range()method 5\colon 6\clause

 

posted on 2017-08-09 22:22  auleon  阅读(245)  评论(0编辑  收藏  举报