This is a Python program that generates a list of perfect squares between 1 and 49 using a loop and a conditional statement. The program first initializes an empty list sqre_list, which will be used to store the perfect squares.
A for loop is used to iterate over the numbers 1 to 49. Within the loop, a variable j is initialized to 1, and a while loop is used to check whether j*j is less than or equal to the current value of i. If j*j is equal to i, the current value of i is a perfect square, and it is added to the sqre_list using the append() method. The value of j is incremented by 1 at the end of each iteration of the while loop.
After the while loop completes, the value of i is incremented by 1, and the for loop moves on to the next value. Finally, the sqre_list is printed to the console using the print() function.
sqre_list=[] for i in range (1,50): j = 1; while j*j <= i: if j*j == i: sqre_list.append(i) j = j+1 i = i+1 print(sqre_list)
[1, 4, 9, 16, 25, 36, 49]
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions