6th class Cycle
1. For element in sequence:
Statement
New Python function range (): Creates a new sequence, all integers, starting with 0, the next element is 1 larger than the previous element, up to the upper limit of the series (excluding the upper limit). Ps:range () Changes in usage in 3.2
For a in range (5):2 print a output:4 15 26 37 4
View Code
2. While condition:
Statement
3, continue, break
7th Lesson function
A = 1def Change_integer (a): a = a + 1 return aprint Change_integer (a) print a#=== (the content followed by "#" in Python is commented, not executed) b = [1 , 2,3]def change_list (b): b[0] = b[0] + 1 return bprint change_list (b) Print B
Take this code as an example, value passing and pointer passing
The first: The parameter is passed an integer variable A, the function operates on it, but does not change the value of A; because the base data type is passed as a parameter to the function, the function copies a variable in memory and does not change the original value of the variable (value pass)
The second one: passing a sequence as a parameter to a function, the value of the sequence changes after the function operation, because the number biographies past is the pointer, the pointer points to the position of the sequence in memory, the function is directly in memory and affects the original variable (pointer passing)
8th, 9 class object oriented
1, through the object can modify the properties of the class, but this is very dangerous , because the object of the class and the object of the subclass are sharing this property, once modified, will affect all objects.
Python Basic Learning (3rd day)