HackerRank Python Solution - Numpy Topic - Arrays

Question1 - Arrays:


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

Input Format

A single line of input containing space-separated numbers.

Output Format

Print the reverse NumPy array with type float.

Sample Input

    1 2 3 4 -8 -10

Sample Output

    [-10. -8. 4. 3. 2. 1.]


import numpy

def arrays(arr):
    # complete this function
    # use numpy.array
    return numpy.array(arr[::-1],float)

arr = input().strip().split(' ')
result = arrays(arr)

No comments:

Post a Comment

You might also like

Deploy your Django web app to Azure Web App using App Service - F1 free plan

In this post, we will look at how we can deploy our Django app using the Microsoft Azure app service - a free plan. You need an Azure accoun...