Q:

Write a NumPy program to create an array of 10 zeros, 10 ones, 10 fives

0

Write a NumPy program to create an array of 10 zeros, 10 ones, 10 fives

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

import numpy as np
array=np.zeros(10)
print("An array of 10 zeros:")
print(array)
array=np.ones(10)
print("An array of 10 ones:")
print(array)
array=np.ones(10)*5
print("An array of 10 fives:")
print(array)

Sample Output:

An array of 10 zeros:
[ 0.  0.  0.  0.  0.  0.  0.  0.  0.  0.]
An array of 10 ones:
[ 1.  1.  1.  1.  1.  1.  1.  1.  1.  1.]
An array of 10 fives:
[ 5.  5.  5.  5.  5.  5.  5.  5.  5.  5.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now