31. Make a decision
Reviewed the Raw_input (">")
if variable = = "Vaule":
EXECUTE statement
32. Loops and Lists
Count = [1, 2, 3, 4, 5]
For I in Count:
Print "This is%d"% i #循环打印出count的值
Count.append (6) #从最后增加值
Count.insert (1,44) #从第二位增加值44
Range (#范围)
33. While loop
In Python programming, a while statement is used to loop the execution of a program, which, under certain conditions, loops through a program to handle the same tasks that require repeated processing. Its basic form is:
12 |
While judging condition: Execute statement ...
|
The execution statement can be a single statement or a block of statements. The judging condition can be any expression, and any value other than 0, or non-null (NULL), is true.
The loop ends when the condition false false is judged.
The execution flowchart is as follows:
34. Access the elements of the list
Animals = [' bear ', ' python ', ' peacock ', ' kangaroo ', ' whale ', ' platypus ']
Print "The 1st animal is at 0 and was a bear.", Animals[0]
Print Count[1]
35. Branches and functions
If "0" in Next or "1" in Next: #两个条件
Exit module
From sys import exit
Exit (0) #退出
def start ():
。。。
Start () #启动函数
36. Design and Commissioning
Tips for debugging (Debug)
1. Do not use "debugger". Debugger the equivalent of a full body scan of the patient. You don't get useful information about something, and you'll find that it outputs an attitude of information that's mostly useless, or just makes you more confused.
2. The best way to debug your program is to print the key variables in each key link you want to check to see if there are any errors.
3. Let the program run in part. Don't wait for a long script to finish writing it before you run it. Write a little, run a little, and then modify a little bit.
37-38 Skip
39, the operation of the list
Build List
ten_things = "Apples oranges Crows Telephone Light Sugar"
Stuff = Ten_things.split (")
Stuff
[' Apples ', ' oranges ', ' Crows ', ' telephone ', ' light ', ' Sugar ']
Join connection
>>> print (". Join (Stuff))
Apples Oranges Crows Telephone Light Sugar
>>> print (' @ '. Join (stuff))
[Email protected]@[email protected]@[email protected]
40. Cute Dictionary
Stupid method to learn python31-40