Write a program in python to print the square table for numbers from 1 to 20.
such as 1^2 = 1, 2^2 = 4, 3^2 = 9 etc.
Answers
Answered by
4
Required program is given below :-
for i in range(1,21):
print(f"{i}^2 = {i* *2} ")
Output is attached in the attachment.
Explanation :-
Here, we used a for loop which runs from 1 to 20. First parameter is starting number and second parameter is ending number ( 21 is excluded so it will go only till 20 ).
We used power operator to find the square of numbers. In python * * is used as exponential or power operator.
Attachments:
Similar questions