Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started