Page 188 - Robotics and AI class 10
P. 188
Output:
[[3 1 4 1]
[7 6 0 1]
[4 2 2 9]]
• Creating two dimensional array of 3 rows and 4 columns with all ones as value :
import numpy as np
a = np.ones((3,4))
print(a)
Output:
[[1. 1. 1. 1.]
[1. 1. 1. 1.]
[1. 1. 1. 1.]]
• Creating two dimensional array of 3 rows and 3 columns with all zeroes as value:
import numpy as np
a = np.zeros((3,3))
print(a)
Output:
[[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]]
• Creating two dimensional array of 3 rows and 4 columns with all six as value:
import numpy as np
a = np.full((3,4),6)
print(a)
Output:
[[6 6 6 6]
[6 6 6 6]
[6 6 6 6]]
• We can create two dimensional (2-D) arrays by passing nested lists to the array() function.
import numpy as np
a = np.array([11,'Arshia',93],[15,'Riddhi',95])
print(a)
Output:
[[11,'Arshia',93]
[15,'Riddhi',95]]
186 Touchpad Robotics & Artificial Intelligence-X

