85.6k views
2 votes
Assume you I have a list of numbers 12, 10, 32, 3, 66, 17, 42, 99, 20. Write a loop that prints each number and its square on a new line. Example: 12 144 10 100 Output: 144 100 1024 9 4356 289 1764 9801 400 1 nums = [12, 10, 32, 3, 66, 17, 42, 99, 20] 2 - for i in nums: 3 print(i**2)

1 Answer

4 votes

nums = [12, 10, 32, 3, 66, 17, 42, 99, 20]

#Get the result.

for i in range(len(nums)):

print(nums[i],"-",nums[i]**2)

Assume you I have a list of numbers 12, 10, 32, 3, 66, 17, 42, 99, 20. Write a loop-example-1
User Ghostrifle
by
5.5k points