1. (Total 20 marks) List and NumPy Array You are required to write codes to perform...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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). 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).
Expert Answer:
Posted Date:
Students also viewed these programming questions
-
Necked Amber purchased a bond for $1,038.90 exactly two years ago. At that time, the bond had a maturity of five years and a coupon rate of 10% (paid semi-annually). Assuming the rates below are the...
-
Explain the reasons that elastomers were developed. Based on the contents of this chapter, are there any substitutes for elastomers? Explain.
-
_____ is the thought that there are invisible barriers to advancement in business for women, as well as other minority employees.
-
What could be key points of a company's anti-fraud program?
-
On May 2, Ottawa Company lends $7,600 to Cortland, Inc., issuing a 6-month, 8% note. At the maturity date, November 2, Cortland indicates that it cannot pay. Instructions (a) Prepare the entry to...
-
I need to know the answer to Actual Cost Incurred, Actual input qty x budgeted price and flexible budget.. You have been invited to interview for an internship with an international food...
-
Reliable Electric is considering a proposal to manufacture a newtype of industrial electric motor which would replace most of itsexisting product line. A research breakthrough has given Reliable at 0...
-
BACKGROUND You work for All Season's Clothing Company (ASCC). ASCC is a privately held company that designs, manufactures and sells (only online) children's clothing for babies up to five years of...
-
Compare and contrast today's airline industry with the pre-deregulation airline industry using the Utilitarianism Ethics System and/or the Kantian Ethics System as theoretical foundations? Provide...
-
You are Professional Accountant ( SA ) for registered accountants. A client of yours in the SME sector is speculating shares on listed company on the JSE. The detail and name of the listed company is...
-
Tyrell Company entered into the following transactions involving short-term liabilities. Year 1 April 20 Purchased $38,000 of merchandise on credit from Locust, terms n/30. May 19 Replaced the April...
-
Compare and contrast opportunities for risk prevention in light of current best practices. Discuss communication practices that are necessary for prevention of risks. Identify the risk methodologies...
-
Suppose you are working as a consultant for a coal company to help them determine how many tns of coal to extract from the earth. The coal company is independent of other companies who wish to use...
-
A condenser (heat exchanger) brings 1 kg/s water flow at 10 kPa quality 95% to saturated liquid at 10 kPa, as shown in Fig. P4.91. The cooling is done by lake water at 20C that returns to the lake at...
-
Calculate \(60^{2} / 50\).
-
Correctly apply the rules for the order of operations to accurately compute the following: \(12 /(-4)+8 \times 9 / 12 \times 2^{3}-24 \times 25 / 10\).
-
Determine which of the following are rational numbers: 1. \(\sqrt{13}\) 2. \(-13 . \overline{21}\) 3. \(\frac{-48}{-16}\) 4. \(-4 \frac{18}{19}\) 5. 14.1131
Study smarter with the SolutionInn App