project_python/2.3_lesson.16.20.py

26 lines
947 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

****Задание 16 Параграф 2.3***
**** А теперь — немного эстетики. Да, таблица умножения работает, но... выглядит-то она скучно.
Пора навести порядок и добавить стиля!
Ваш новый заказчик просит:
одинаковую ширину столбцов,
выравнивание по центру,
и — внимание! — рамки между ячейками.****
if name == "main":
size = int(input())
ceil_width = int(input())
string_length = size * ceil_width + (size - 1)
for row in range(size):
for column in range(size):
print(f'{((row + 1) * (column + 1)): ^{ceil_width}}', end='')
if column == size - 1:
print()
else:
print('|', end='')
if row + 1 != size:
print('-' * string_length)