lesson 2 2019/10/16

// take the remainder divisible%
! = Not equal
= Assignment
== equal
 
Or and not logical operators
The principle of operation calculated from left to right in principle to take a short-circuit
For expression before and after and if the preceding condition is false, and then it must be false, some false results, the expression that will not be calculated
For the foregoing conditions or if true, then the latter will not be calculated or expression
No priority, priority parentheses
True False true and false judgment, the first capital
 
Expressions and statements that an operator can be assigned to variables
 
while loop structure
 
while conditions:
    print('any')
    print('any')
 
Guess the age of the game upgrade
 
age_answer=50
 
flage=True
 
while flage:
    age_gusse = int(input('guess age:'))
    if age_answer==age_gusse :
        print('you got it!')
        flake = False
    elif age_answer>age_gusse :
        print('try bigger')
    else :
        print ( 'try slams')
print('good game')
 
 
break out of the entire cycle
 
age_answer=50
 
while True:
    age_gusse = int(input('guess age:'))
    if age_answer==age_gusse :
        print('you got it!')
        break
    elif age_answer>age_gusse :
        print('try bigger')
    else :
        print ( 'try slams')
print('good game')
 
 
continue to jump out when the cycles
 
end = content by the end of the end of the sentence to be output
 
\ T denotes a tab
\ N for new line
 
line = int (input ( 'equilateral triangle:'))
 
while line>0:
    tmp=line
    while tmp>0:
        print('*',end='')
        tmp-=1
    print()
    line-=1
 
Multiplication table
 
num1=1
while num1<=9:
    num2 = 1
    while num2<=num1:
        print(str(num1)+'*'+str(num2)+'='+str(num1*num2),end='\t')
        num2 + 1 =
    num1+=1
    print()

Guess you like

Origin www.cnblogs.com/sky-xintu/p/11682172.html