Answer to Question #295631 in Python for Michael

Question #295631

write a python function Square_List(A)  that takes a list as an input and returns another list of lists that has the first number as the same number given in the input list and the second number be the square of the first number.[[1, 1], [2, 4], [5, 25], [6, 36]]


1
Expert's answer
2022-02-09T05:55:49-0500
def Square_List(A):
    rez_list = [[0] * 2 for i in range(len(A))]
    for i in range(len(A)):
        rez_list[i][0] = A[i]
        rez_list[i][1] = A[i] ** 2
    return rez_list

print("Enter the list separated by a space:")
a = input().split()
for i in range(len(a)):
    a[i] = int(a[i])
print(Square_List(a))

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS