Menu Close

Return an array of the squares of each number.

Given an array of integers A sorted in non-decreasing order, return an array of the squares of each number,
 also in sorted non-decreasing order.

Input: 
-1 -2 60 100

Output: 
1 4 3600 10000
arry=list(map(int,input('Enter a list of arrays : ').split(' ')))

Sorted_arry=[x**2 for x in arry]

print(*Sorted_arry)  # prints list in single line with spaces and not in list with sqr-braces  

Input_1:
Enter a list of arrays : 56 65 89 90 105 110

Output:
3136  4225  7921  8100  11025  12100


Input_2:
Enter a list of arrays : 2 4 6 8 10

Output:
4  16  36  64  100


executed using python3

More Q