4.19 Daily practice

1: How to delete duplicate items in the list

list(set(list))

2: The difference between assignment, shallow copy and deep copy

Assignment: the mapping between variables and values ​​in memory;

Shallow copy: only copy the first layer element address copy.copy;

Deep copy: open a new space for all the elements of the layer separately copy.deepcopy ()

3: The role of pass

Placeholder

The same usage as

4: How to generate a random number

import random
random.random()

Random number is decimal

5: How to get the second largest value in the list

a = set([45,88,96,-32,6,0])
b = sorted(a)
b_new = res[-2]
print(b_new)

 

Guess you like

Origin www.cnblogs.com/ljy123/p/12735218.html