2022-10-14 22:03:25 +00:00
|
|
|
# Show a table of the squares of the first four numbers
|
2022-11-10 23:20:38 +00:00
|
|
|
print(" {:1s} | {:>3s} | {:>7s}".format("n", "n²", "2**n"))
|
2022-10-14 22:03:25 +00:00
|
|
|
for n in range(1, 21):
|
2023-05-16 20:14:36 +00:00
|
|
|
print("{:2d} | {:3d} | {:7d}".format(n, n**2, 2**n))
|
2022-10-14 22:03:25 +00:00
|
|
|
|
|
|
|
# Modify the program to show the squares of 1..20. (Use the range function.)
|
|
|
|
# Also, add a column to show 2**n. Adjust the formatting.
|