1.python Interpretation Execution principle
Python code--byte code--machine code--Computer
Each run is converted to bytecode, and then the virtual machine converts the bytecode into machine language, which can then be run on the hardware.
2. Variables
The value of the program during its run is the amount allowed to change.
Variable naming rules:
①. Numbers, letters, underscores
②. Cannot start with a number
③. Cannot be a keyword inside python
3. Data type
Digital
String: "or" or "" "" "
Boolean value: TRUE or False
4. Enter
1 # -*-coding:utf-8-*- 2 3 4 # assigning user-entered content to the name variable 5 name=raw_input ("Please enter user name:")67# Print input 8 Print Name
Weak or invisible when entering a password, the Getpass method available in the Getpass module
1 # -*-coding:utf-8-*- 2 3 Import Getpass 4 5 pwd = Getpass.getpass (" Please enter password:")
5. Conditional statement (IF...ELSE)
1 #print their permissions based on what the user has entered2 3 #Alex--Super Admin4 #Eric--General Administrator5 #Tony,rain--- business executives6 #other--Ordinary users7 8Name = Raw_input ('Please enter user name:')9 Ten ifName = ="Alex": One Print "Super Admin" A elifName = ="Eric": - Print "General Administrator" - elifName = ="Tony" orName = ="Rain": the Print "Business Supervisor" - Else: - Print "Normal User"
6.while Cycle
①. Basic Loops
while Conditions: # Loop Body # if the condition is true, then the loop body executes # if the condition is false, then the loop body does not perform
②.break (for exiting all loops)
while True: Print " 123 " Break Print " 456 "
③.continue (used to exit the current loop and continue the next loop)
while True: Print " 123 " Continue Print " 456 "
Small Programming (http://www.cnblogs.com/wupeiqi/articles/5433925.html)
1. Use while loop input 1 2 3 4 5 6 8 9 10
2. For all numbers of 1-100
3. All odd numbers in output 1-100
4. All even numbers in output 1-100
5, Beg 1-2+3-4+5 ... 99 of all numbers of the and
6. User Login (three chance retry)
Python development "1th article"