" " Date: September 5-September 30 Requirements: 1. Summary of the book contents, finishing in the blog Park notes upload 2. After all the exercises in the course Note: "#" After the addition of the notes (42 pages per day, you can guarantee to read this book at the end of the month) "Key Notes" "chapter Exercises"-Heading 1, level two headings- Heading 2, Notes outline title, exercise title-Bold, 16px"
Key notes
I. Assignment statements
With an assignment statement, the object is assigned to a noun with the following characteristics:
- An assignment statement establishes an object reference value
- Variable names are created when they are first assigned
- Variable names must be assigned before they are referenced
- Some actions to perform an implicit assignment
Two. Extended sequence unpacking in Python3.0
In Python3.0, we can use a name with a single asterisk in the target to make a more general match. Examples are as follows:
>>> list = [1,2,3,4]>>> a,*b = list>>> a1>>> b[ 2, 3, 4]>>> *a,b = list>>> a[1, 2, 3]>>> b 4
>>> A = b = []>>> b = [].append ('a')>>> a[] >>> ID (a)42958520>>> ID (b)1898129408
Three. Printing
>>> log = open ('Log.txt','a')>>> x ='x'>>> y ='y'>>> z ='Z'>>>Print(X,y,z,file =log)>>>log.close ()>>>Print(Open ('Log.txt'). Read ()) x y z
This chapter exercises:
1. Give three ways to assign three variables to the same value.
Answer: A,b,c = 1,1,1
A=b=c=1
A = 1;b = 1; c = 1
2. What do you need to be aware of when assigning three variables to a mutable object?
Answer: a=b=[], a= a.append (), A is the value of the none,b change
3. L = L.sort () What's wrong?
A: The list sort method, like the Append method, is also a modification to the main list: Returns none, rather than returning the list of its modifications. Assigning a value to L will set L to none, not the sorted list. The new built-in function sorted sorts any sequence and returns a new list with sorted results, as this is not a modification in place.
>>> b = ['a','x','z' ]>>> ID (b)43863176>>> B = sorted (b)>>> ID (b) 43813024
4. How do I use the PRINT statement to send text to an external file?
Answer: print (x,y,file = f)
11th assignment, expression, and printing of the Python Learning Handbook 4th