1. (8 pts) We define a list ls = [2,1, 3, 5, 4, 6, 9, 8, 7] in Python. (a) What is the slicing command to get [5,4,6,9]?
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
1. (8 pts) We define a list ls = [2,1, 3, 5, 4, 6, 9, 8, 7] in Python. (a) What is the slicing command to get [5,4,6,9]?
question. arr = np.array([[14, 9, 12], [14, 3, 10], [13, 13, 2], (a) arr[:, 2] = (b) arr[:4, :2] = 3. (12 pts) [17, 3, 17], [13, 18, 19], [0, 15, 10]]) (1) a = list(range(5)) b=a b[0] = 10 What is a and b? (4 pts) (2) a = list(range(5)) b=a[:] b[0] = 10 What is a and b? (4 pts) 1 (2 pts) (3 pts) (3) Why the results of a and b are different in the two cases? (4 pts)
1. (8 pts) We define a list ls = [2,1, 3, 5, 4, 6, 9, 8, 7] in Python. (a) What is the slicing command to get [5,4,6,9]? (b) What is the slicing command to get the last four numbers, If you do not know the length of the list? (hint: negative numbers)? (c) What is Is *2? (d) What is np.array(ls)*2? 2. (5 pts) write down the output of each