Answered step by step
Verified Expert Solution
Question
1 Approved Answer
For each instruction below, show the code and the results from running the code following each of the instructions below. Answer any questions. a) Creating
- For each instruction below, show the code and the results from running the code following each of the instructions below. Answer any questions.
a) Creating Arrays
1) Make a one-dimensional array named "basic_arr" that contains four integer values.- 2) Make an array named 'main_arr" that contains 16 values from 10 to 25 that are formatted as four rows and four columns.
3) Make an array named 'sub_arr" that contains 16 random values that are formatted as four rows and four columns.
Question:
• How does a vector and matrix differ?
b) Accessing Array Elements and Attributes
1) Use "main_array" and indexing to display the different elements in the array
2) Display "main_arr"'s attributes:
dimension
size
shape
data type
c) Aggregate Functions
1) Display the following statistical information about the data stored in "main_arr":
Sum
mean
median
minimum value
maximum value
standard deviation
d) Arithmetic Operations, Matrix Operations, Broadcasting, and Comparisons
1) Use "main_arr" and "sub_array" to demonstrate the following arithmetic operations:
addition
subtraction
multiplication
division
2) Use "main_arr" and "sub_array" to demonstrate finding the matric product of the two arrays.
Question:
• How do matrix operations differ from normal arithmetic operations?- 3) Use "main_arr" and "basic_array" to demonstrate broadcasting using addition
Question:
• What does broadcasting do?
4) Using "main_arr" to demonstrate comparison. Find all of the values that are greater than or equal to 7
Question:
• What modifications to the code would be required to save all of the values greater than or equal to 7 in a new array?
e) Joining, Splitting, and Splicing Arrays
1) Use "main_arr" and "sub_array" to demonstrate joining two arrays both horizontally and vertically.
2) Use "main_arr" to demonstrate splitting the array as follows:
Two 2 x 4 arrays
Two 4 x 2 arrays
3) Use "main_arr" to demonstrate slicing the array as follows:
An array that contains just the data from the third row
An array that contains data from the third column
Question:
• How does splitting differ from slicing?
f) Saving and Loading Arrays
1) Save "sub_arr" to an external file named "saved_sub.npy".
2) Load an external file named "saved_sub.npy".
Question:
• Why might a text file be used to save data rather than a binary file?
Step by Step Solution
★★★★★
3.23 Rating (150 Votes )
There are 3 Steps involved in it
Step: 1
a Creating Arrays 1Make a onedimensional array named basicarr that contains four integer values output basicarr 1 2 3 4 2 Make an array named mainarr that contains 16 values from 10 to 25 that are for...
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