11. What is the Python library used for scientific computing and is a basis for Pandas?
- Requests
- Tkinter
- Numpy
- datetime
12. What attribute is used to retrieve the number of elements in an array?
- a.size
- a.ndim
- a.shape
- a.dtype
13. How would you change the first element to "10" in this array c:array([100,1,2,3,0])?
- c[0]=10
- c[4]=10
- c[2]=10
- c[1]=10
14. What attribute is used to return the number of dimensions in an array?
- a.ndim
- a.shape
- a.size
- a.dtype
Module 4 Graded Quiz
15. What is the result of the following lines of code?
a=np.array([-1,1])
b=np.array([1,1])
np.dot(a,b)
- array([0,2])
- 1
- 0
16. How do you perform matrix multiplication on the numpy arrays A and B ?
- A+B
- A*B
- np.dot(A,B)
17. What values does the variable out take if the following lines of code are run?
X=np.array([[1,0,1],[2,2,2]])
out=X[0:2,2]
out
- array([1,0])
- array([1,2])
- array([1,1])
18. What is the value of Z after the following code is run?
X=np.array([[1,0],[0,1]])
Y=np.array([[2,1],[1,2]])
Z=np.dot(X,Y)
- array([[2,1],[1,2] ])
- array([[2,0],[1,0]])
- array([[3,1],[1,3] ])
Shuffle Q/A 2
19. Consider the following text file: Example1.txt:
This is line 1
This is line 2
This is line 3
What is the output of the following lines of code?
with open("Example1.txt","r") as File1:
file_stuff=File1.readline ()
print(file_stuff)
- This is line 1
This is line 1
This is line 2
This is line 3
This is line 1
This is line 2
20. What do the following lines of code do?
with open("Example1.txt","r") as file1:
FileContent=file1.readlines()
print(FileContent)
- Read the file “Example1.txt”
- Write to the file “Example1.txt”
- Append the file “Example1.txt”