Learn now: https://edu.csdn.net/course/play/26676/338763?utm_source=blogtoedu
Boolean type Bool: The values are only True and False.
Four arithmetic operations can be performed with numbers.
True=1 False=0
bool() checks whether an object is true or false.
Empty and empty strings are both false
The space is True.
Empty list, empty string, empty dictionary are all false.
Comparison operation: return True if the relationship is established, return False if the relationship is not established.
Normally, the same type is compared.
logic operation:
and:A and B
Short-circuit calculation: first look at whether A is true or false, if it is false, return the A object, if A is true, then return B.
or:A and B
Short-circuit calculation: If the A object is true, then return the A object, if the A object is false, then return the B object.
not: Negate all objects behind not.
Simple statement:
Import module
import module as new_name change the name of the imported module
Import math as shuxue use shuxue instead of math
From module import function Import the specified function from a module.
After from math import pi is introduced, you don't need to write math.pi anymore, you can write pi directly.
From module import function as new_name Import the specified function from a module and change the name.
From module import * Import all the functions under this module. It is discouraged to use, which may cause the same name with some functions in the program.
Assignment statement:
Basic form
Variable = object
Other tricks:
a=1,2,3
This is assembled into tuples.
a,b,c = 1,2,3
a,_,c = 1,2,3, as long as 1 and 3, 2 are not needed. _ Serve as a place.
a, *b = 1,2,3 a=1 b=[2,3]
a= a+1 --> a+=1 Incremental variable.