Write a program to create a tuple containing squares of integers 1 through 50 using a
for loop:
Answers
Answered by
12
Answer:
The program in python does like:
__________________________
a=[]
for i in range(1,51):
a.append(i**2)
print(tuple(a))
___________________________
Consider the image if you're having problem viewing this code.
Explanation:
Since you can't append values in tuples, I used a list and then converted it to a tuple before printing.
Attachments:
Answered by
4
t = tuple()
for x in range(1, 51): t = (*t, x * x)
print(t)
Similar questions