607 views
12 votes
12 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)

User Ken Wheeler
by
2.6k points

1 Answer

7 votes
7 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 Bohoo
by
3.1k points