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
8.7k points

Related questions

asked Oct 21, 2024 144k views
Rekildo asked Oct 21, 2024
by Rekildo
8.4k points
1 answer
4 votes
144k views
asked Apr 12, 2017 111k views
Lig asked Apr 12, 2017
by Lig
7.5k points
1 answer
3 votes
111k views