Question: 1. (Total 20 marks) List and NumPy Array You are required to write codes to perform the following tasks using Python list structure and

1. (Total 20 marks) List and NumPy Array You are required to

1. (Total 20 marks) List and NumPy Array You are required to write codes to perform the following tasks using Python list structure and NumPy Array structure. Fill in the table provided in the Answer Book. (a) (6 marks) Create a Python list and a NumPy Array, named my_list and my_nparray respectively, with numbers -1 to -10. Instead of hardcoding the numbers, you are required to use the function range() for the Python list and arange() for the NumPy Array to create the data structure. (b) (2 marks) Find the number of items in the Python list and the NumPy Array created in (a). (c) (2 marks) Output the item at index 0 of the Python list and the NumPy Array created in (a). (d) (2 marks) Using slicing and negative indexing, output the last 3 items in the Python list and the NumPy Array created in (a). (e) (2 marks) Change the third element in the Python list and the NumPy Array to the last digit of your student ID. (f) (4 marks) Convert all the elements in the Python list and the NumPy Array to their absolute values. (g) (2 marks) Append the number 99 to the end of Python list and the NumPy Array resulted in (f).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!