One: Python basics
1. File suffix name:. py
2, Python2 to read Chinese in the file header write:-*-coding:utf8-*-
3. Input uses n as a variable, substituting a value for a change
n = input (' Enter user name: ') waits for the user to enter a value, the value entered by the user will be assigned to the N,n to refer to what the user entered.
4, the variable can only be composed of letters, numbers, underscores.
Cannot start with a number.
You can't start with a python keyword:
5, n= "Pepper" assignment value
n== "Pepper" comparison
Two: string
String: The part of quotation marks is called a string.
Character: The string content that is quoted by quotation marks is called a character.
string addition :
" Alex " "sb"= n1 + n2 print N3: ALEXSB
String multiplication:
" Alex " = N1 *10 print N2: Alexalexlaex ..... (10 Alex)
Digital:
For example:
N1 = 9= 2 = n1 + n2 = n1- n2 = N1 *= n1/= n1% n2< c10/> Division takes remainder = N1 * * N2
N3 = n1//N2 Division distributor
Three: F conditional statements
ifINP = ="Senior Member" Print("Beauty")elifINP = ="Platinum Member" Print("Morgan Stanley")elifINP = ="Platinum Members" Print("A little star .")Else:Print("Chengguan")Print("start the service.")
Four: While Dead loop
count=0 while Count < : print( count)= Count +1Print ("1, 2, 3,,")
Python base, string, and if condition statements