write a python program to create a list containing the squares of integers 1 through 50
Answers
Answered by
2
Required Answer:-
Question:
Write a Python program to create a list containing the squares of integers from 1 to 50.
Solution:
Here is the code. This is written in Python.
l=[]
for i in range(1,51):
l.append(i*i)
print(l)
Another way,
l=[i*i for i in range(1,51)]
print(l)
We have created a loop. After each iteration, value of i is incremented by 1. Square of i is added in the list after each iteration.
Output is attached.
Attachments:




Similar questions