zeros

The zeros tool returns a new array with a given shape and type filled with $\mbox{o}$'s.

import numpy

print numpy.zeros((1,2))                    #Default type is float
#Output : [[ 0.  0.]] 

print numpy.zeros((1,2), dtype = numpy.int) #Type changes to int
#Output : [[0 0]]

ones

The ones tool returns a new array with a given shape and type filled with $\mbox{I}$'s.

import numpy

print numpy.ones((1,2))                    #Default type is float
#Output : [[ 1.  1.]] 

print numpy.ones((1,2), dtype = numpy.int) #Type changes to int
#Output : [[1 1]]   

Task  

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.

Input Format

A single line containing the space-separated integers.

Constraints

$1\leq\text{each integer}\leq3$

Output Format

First, print the array using the numpy.zeros tool and then print the array with the numpy.ones tool.  

Sample Input 0
3 3 3

Sample Output 0
[[[0 0 0]
  [0 0 0]
  [0 0 0]]

 [[0 0 0]
  [0 0 0]
  [0 0 0]]

 [[0 0 0]
  [0 0 0]
  [0 0 0]]]
[[[1 1 1]
  [1 1 1]
  [1 1 1]]

 [[1 1 1]
  [1 1 1]
  [1 1 1]]

 [[1 1 1]
  [1 1 1]
  [1 1 1]]]

Explanation 0

Print the array built using numpy.zeros and numpy.ones tools and you get the result as shown.

Source: hackerrank | Difficulty: EASY


Solutions:
import numpy as np
ip = tuple(map(int, input().split()))
print(np.zeros(ip, dtype=int))
print(np.ones(ip, dtype=int))


import numpy as np
N = list(map(int, input().split()))
zer = np.zeros(N, int)
one = np.ones(N, int)
print(zer)
print(one)


import numpy
d = list(map(int, input().split()))
print(numpy.zeros(d, int))
print(numpy.ones(d, int))


import numpy
size = tuple(map(int, input().strip().split()))
print(numpy.zeros(size, int))
print(numpy.ones(size, int))


import numpy
N = list(map(int, input().split()))
print(numpy.zeros(N, int))
print(numpy.ones(N, int))


import numpy as np
dims = list(map(int, input().split()))
print(np.zeros(dims, dtype=int))
print(np.ones(dims, dtype=int))


import numpy
a = tuple(numpy.array(input().split(), int))
b = numpy.zeros(a, int)
c = numpy.ones(a, int)
print(b)
print(c)


import numpy
D = tuple(map(int, input().split()))
print(numpy.zeros(D, dtype=int), numpy.ones(D, dtype=int), sep='\n')


import numpy
dim = tuple(map(int, input().split()))
print(numpy.zeros(dim, int))
print(numpy.ones(dim, int))


import numpy as np
N = [int(i) for i in input().split()]
print(np.zeros(tuple(N), dtype='int32'))
print(np.ones(tuple(N), dtype='int32'))


import numpy as np
dims = tuple((int(i) for i in input().split()))
print(np.zeros(dims, int))
print(np.ones(dims, int))


import numpy
n = list(map(int, input().split()))
print(numpy.zeros(n, int))
print(numpy.ones(n, int))


import operator
import numpy

def read_f(f):
	return f(input())

def read_f_words(f):
	return mapl(f, input().split())

def mapl(f, x):
	return list(map(f, list(x)))
ds = read_f_words(int)
print(numpy.zeros(ds, int))
print(numpy.ones(ds, int))


import numpy
dims = tuple(map(int, input().split()))
print(numpy.zeros(dims, int))
print(numpy.ones(dims, int))


import numpy
list_n = list(map(int, input().split()))
print(numpy.zeros(list_n, dtype=int))
print(numpy.ones(list_n, dtype=int))


import numpy
a = tuple(map(int, input().split(' ')))
print(numpy.zeros(a, dtype=int))
print(numpy.ones(a, dtype=int))


import numpy as np

def main():
	a = tuple(map(int, input().split()))
	print(np.zeros(a, int))
	print(np.ones(a, int))
main()


import numpy
shape = tuple(map(int, input().strip().split()))
print(numpy.zeros(shape, dtype=int))
print(numpy.ones(shape, dtype=int))


from numpy import *
N = tuple([int(x) for x in input().split()])
print(zeros(N, dtype=int))
print(ones(N, dtype=int))


import numpy
dims = [int(x) for x in input().strip().split()]
print(numpy.zeros(tuple(dims), dtype=numpy.int))
print(numpy.ones(tuple(dims), dtype=numpy.int))


import numpy
n_ar = list(map(int, input().split()))
n = tuple(n_ar)
print(numpy.zeros(n, dtype=numpy.int))
print(numpy.ones(n, dtype=numpy.int))


import numpy
N = tuple(map(int, input().split()))
print(numpy.zeros(N, int))
print(numpy.ones(N, int))


import numpy
s = tuple(map(int, input().split()))
print(numpy.array(numpy.zeros(s), int))
print(numpy.array(numpy.ones(s), int))


import numpy as np
tup = list(map(int, input().split()))
print(np.zeros(tup, dtype=int))
print(np.ones(tup, dtype=int))


import numpy
N = [int(x) for x in input().split()]
print(numpy.zeros(N, dtype=int))
print(numpy.ones(N, dtype=int))


import numpy as np
n = tuple(map(int, input().split()))
print(np.zeros(n, int))
print(np.ones(n, int))


import numpy as np
d = tuple(map(int, input().split()))
print(np.zeros(d, dtype='int'))
print(np.ones(d, dtype='int'))