One. Python First program
Print ("Hello World")
Two. naming rules for variables
1. Alphanumeric Underline composition
2. Cannot start with a number, cannot contain special characters and spaces
3. Cannot be named with a reserved word
4. Cannot be named in Chinese
5. The variable name defined should make sense
6. Hump-Type life, underline word segmentation
7. Variable names are case-sensitive
Three. If condition judgment
If a<b: print ("Yes") Else: print ("No")
If a>b: print ("A>b") elif a==b: print ("a=b") else: print ("A<b")
Python does not use curly braces and needs to be indented.
Four. Annotation methods
# single-line comment ' multiline comment ' ' "" "Multiline Comment" "
Five. Python's input
Input ("Please enter:")
Six. Python's output
Print ("abc" + "Def")
Concatenation of strings using "+", int type and string type can not be spliced, you need to force type conversion.
Seven. Select the maximum value of the program
Num1=int (Input ("NUM1:")) Num2=int (Input ("num2:")) Num3=int (Input ("num3:")) max_num=0if num1>num2: max_num= Num1else: max_num=num2if num3>max_num: max_num=num3print ("Maximum value:" Max_num)
Basic Python Learning 1