Page 1 of 1

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]?

Posted: Fri Jul 01, 2022 5:42 am
by answerhappygod
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 1
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 1 (76.83 KiB) Viewed 34 times
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 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)