1. Conditional Expressions:
If.. Elif...else
2. Operators
A+=b #等效a =a+b, add
A-=b #等效a =a-b, subtraction
A*=b #等效a =a*b, multiply
A/=b #等效a =a/b, divide
A%=b #等效a =a%b, take the mold
A**=b #等效a =a**b, Power assignment operation
A//=b #等效a =a//b, take the integer division assignment operation
he.py
#Coding=utf8#Logical ExpressionsdefShow1 (): Age=19ifage<0:Print("Unknown") elif(age>0 andAge<=18): Print("Minors") Else: Print("has grown")#operatordefShow2 (): a=4b=3a+=b#equivalent a=a+b, added Print(str (a)) a-=b#equivalent a=a-b, subtraction Print(str (a)) a*=b#equivalent a=a*b, multiplied Print(str (a)) a/=b#equivalent a=a/b, dividing Print(str (a)) a%=b#equivalent a=a%b, modulo Print(str (a)) a**=b#equivalent a=a**b, power assignment Operation Print(str (a)) a=b#equivalent a=a//b, divisible assignment Operation Print(str (a)) STRs=[7,4,60] #Check if this value exists if(AinchSTRs):Print("This value exists") Else: Print("This value does not exist")
Calling code:
Python 3.6.1 (V3.6.1:69C0DB5, Mar, 17:54:52) [MSC v.1900"copyright" credits"or"license ()" for more Information. from import *>>> show1 () adult >>> show2 ()74124.01.01.00.0 This value does not exist
Conditional expressions, operators for Python basics