2022-10-19 08:47:23 +00:00
|
|
|
# Example: Print a multiplication table
|
|
|
|
# Like:
|
|
|
|
# 1 x 1 = 1
|
|
|
|
# 1 x 2 = 2
|
|
|
|
# ...
|
|
|
|
# 10 x 10 = 100
|
|
|
|
#
|
|
|
|
# Make the program print an empty line after each group of ten.
|
|
|
|
# Also, use format specifiers to align the numbers.
|
|
|
|
#
|
|
|
|
# JMR 2019
|
|
|
|
|
|
|
|
def main():
|
2023-05-16 20:00:37 +00:00
|
|
|
for i in range(1, 11):
|
|
|
|
table(i)
|
|
|
|
print()
|
|
|
|
|
2022-10-19 08:47:23 +00:00
|
|
|
|
|
|
|
def table(n):
|
2023-05-16 20:00:37 +00:00
|
|
|
for i in range(1, 11):
|
|
|
|
print(f'{n} x {i} = {n * i}')
|
|
|
|
|
2022-10-19 08:47:23 +00:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2023-05-16 20:00:37 +00:00
|
|
|
main()
|