Skip to main content

13 | for loop; output squares

What it is is:

squares.py

# This program uses a loop to display a
# table showing the numbers 1 through 10
# and their squares.

# Print the table headings.
print('Number\tSquare')
print('--------------')

# Print the numbers 1 through 10
# and their squares.
for number in range(1, 11):
square = number**2
print(f'{number}\t{square}')