We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Python
- Numpy
- Zeros and Ones
- Discussions
Zeros and Ones
Zeros and Ones
Sort by
recency
|
299 Discussions
|
Please Login in order to post a comment
ar = list(map(int,input().split()))
ex = (np.zeros(ar, dtype = int))
ey = (np.ones(ar, dtype = int))
print(ex)
print(ey)
import numpy as np
a = input().strip() b = list(map(int,a.split()))
zeros_array = np.zeros(b, dtype=int) ones_array = np.ones(b, dtype=int)
Print the arrays
print(zeros_array) print(ones_array)
import numpy as np
M = list(map(int, input().split()))
print(np.zeros(M, dtype=int)) print(np.ones(M, dtype=int))
import numpy as np
def zero_one(x): list_zero_one = ['zeros','ones'] for i in list_zero_one: func = getattr(np, i) print(func(tuple(x), int))
inputs = list(map(int, input().split())) zero_one(inputs)
Zeros and Ones(Create array)
import numpy as np l = list(map(int, input().split()))
zerosArr = np.array(list(np.zeros(([i for i in l]),dtype=int))) onesArr = np.array(list(np.ones(([i for i in l]),dtype=int))) print(zerosArr) print(onesArr)