Niuke python exercise 2

1

insert image description here
Analysis: assignment operation (a=XX, b=a), a, b point to the same memory space. When a and b are immutable types, a changes, a value changes, and id changes, but b does not change, and b’s id does not change; when a and b are mutable types, a changes, a value changes, and id No change, b changes, b's id remains the same.

2

insert image description here
Parsing: Tuples are immutable data types.

3

insert image description here

4

insert image description here
Analysis: Shallow copy: Shallow copy only copies the parent object, not the child object, but only points to the memory address of the child object. In this way, if the parent object of a changes, the parent object of c remains unchanged, and if the child object of a changes, the child object of c The object changes.
Deep copy: deep copy d completely copies the parent object and child object of a, and a and d do not affect each other.

5

insert image description here
Parsing: bar()()

Generally speaking, to call a function is to add a parenthesis. If you see a parenthesis after the parentheses, it means that the first bar function returns a function, and if there are parentheses after it, it means that the previous one also returns a function. and so on.

6

insert image description here
Parse:
insert image description here

Guess you like

Origin blog.csdn.net/xiaoyurainzi/article/details/132490247