In this Arrays problem, You are given a space-separated list of numbers. Your task is to print a reversed NumPy array with the element type float.

HackerRank Arrays solution in python


Problem solution in Python 2 programming.

# See https://www.hackerrank.com/challenges/np-arrays
# "You are given a space separated list of numbers.
# Your task is to print a reversed NumPy array with the element type float."

import numpy

print numpy.array(map(float, raw_input().split()), float)[::-1]


Problem solution in Python 3 programming.

def arrays(arr):
   #revrser array first, convert to float array with numpy
   return(numpy.array(arr[::-1], float))


Problem solution in pypy programming.

import numpy


def main():
    
    N = numpy.array(list(raw_input().strip().split()), float)
    r_N = N[::-1]    
    print(r_N)
    
main()# Enter your code here. Read input from STDIN. Print output to STDOUT


Problem solution in pypy3 programming.

# Enter your code here. Read input from STDIN. Print output to STDOUT
import numpy as np
a=input().split()
z=np.array(a,float)
#z = np.array(input().split(), float)
print (z[::-1])