Action: Mouse can drag code and comments
Print No Line break
Print ("Hello, end="----")
Print ("Luhan, end="----"")
Print (i,end= "--")
\ n Plus string in front
String% variable formatted output
names = "Luhan"
Print ("Name is:%s"%names)
multiple outputs ()
edu = "Undergraduate"
Address = "Shunyi"
Print ("Education is:%s live in%s"% (edu,address))
%5D%05d-occupied
Student_no = 1
Print ("study number is%5d"%student_no) #占5位
Print ("study number is%05d"%student_no) #占5位, preceded by the
%.3F Reserved Decimals
Price = 30.666
Print ("Price is:%.3f"%price) # Default 6-bit decimal%.3f is a shorthand for%0.3f, reserved three decimal places
% OUTPUT%
Scale = 10
Print ("Scale of data is%.2f%%"%scale)
Input inputs: input (hint information) is typed in string type
Conversion: Int (variable) float (variable) str (variable)
String decimals cannot be converted to integral type
b = "12.33" b = int (b) Error
Floating-point type can be converted to integral type
b = 12.33 B = Int (b) No problem
Two number swaps
A = 10
b = 20
A, B = b,a
Power to fetch quotient
Python xor, bitwise, and
Priority: () > Arithmetic > Compare > Logic > Assignment + = 、...、%=,//= calculation assignment
result = 3 * 5 > 4-2 < 1
If statement judgment, two number comparison without float type float
If, if else, if elif if
Random number generation
Import Random
n = random.randint (0,2) # [0,2] 0-2 generate random number
Next day Python input, if statement, etc.