Answer to Question #288445 in Python for CMmm

Question #288445

Construct a list of first 100 natural numbers.Create a two dimensional array with 10



rows and whose each row contains 10 columns and each number in this array is the



square of the number from your constructed list.



For example : [[1,4,9,...,100],[121,144,...],......,

1
Expert's answer
2022-01-18T08:37:54-0500
# Create a list of first 100 natural numbers
L = list(range(1,101))

# Create a two dimentional array 10x10
array = [[0]*10 for i in range(10)]

# fill the array by squared numbers from the list
for i in range(len(L)):
    row = i // 10
    col = i % 10
    array[row][col] = L[i]*L[i]

print(array)

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