In this zero and One’s problem, You are given the shape of the array in the form of space-separated integers, each integer representing the size of different dimensions, your task is to print an array of the given shape and integer type using the tools numpy.zeros and numpy.ones.
Problem solution in Python 2 programming.
import numpy N = map(int, raw_input().split()) print numpy.zeros(N, dtype = numpy.int) print numpy.ones(N, dtype = numpy.int)
Problem solution in Python 3 programming.
import numpy nums = tuple(map(int, input().split())) print (numpy.zeros(nums, dtype = numpy.int)) print (numpy.ones(nums, dtype = numpy.int))
Problem solution in pypy programming.
# Enter your code here. Read input from STDIN. Print output to STDOUT import numpy input_number=tuple(map(int,raw_input().strip().split())) print numpy.zeros(input_number, dtype = numpy.int) print numpy.ones(input_number, dtype = numpy.int)
Problem solution in pypy3 programming.
# Enter your code here. Read input from STDIN. Print output to STDOUT import numpy as np dims = input().split() dims = [int(i) for i in dims] print(np.zeros(tuple(dims),dtype=np.int)) print(np.ones(tuple(dims),dtype=np.int))