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

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
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]?

Post 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 33 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)
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply