Question 1
a = np.array([[11,22,34],
[48,56,60]])
b = np.array([[18,69,87],
[52,26,35]])
Answer:
Question 1 Output:
array([[29,91,121],
[100,82,95]])
Question 2
a = np.array([[8,9,10],
[25,35,58]])
Answer:
Question 2 Output
array([[24,27,30],
[75,105,174]])
Question 3
x = np.zeros(10)
print(x)
print("Update eighth value to 11")
Answer:
print(x)
Question 3 Output
[0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
Update fifth value to 66 and eighth value to 45
[0. 0. 0. 0. 0. 66. 0. 0. 45. 0.]
import numpy as np
print("Question 1:")
a = np.array([[11,22,34], [48,56,60]])
b = np.array([[18,69,87], [52,26,35]])
print("Array a:")
print(a)
print("Array b:")
print(b)
c = a + b
print("Ansver:")
print(c)
# -----------------
print()
print("Question 2:")
a = np.array([[8,9,10], [25,35,58]])
print("Array a:")
print(a)
c = a * 3
print("Ansver:")
print(c)
# -----------------
print()
print("Question 3:")
x = np.zeros(10)
print(x)
print("Update eighth value to 11")
x[8] = 11
print(x)
# -----------------
print()
print("Question 4:")
x = np.zeros(10)
print(x)
print("Update fifth value to 66 and eighth value to 45")
x[5] = 66
x[8] = 45
print(x)
Comments
Leave a comment