Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def gen_table(nums, stop=12):
- for num in nums:
- print(gen_title(num))
- for x in range(1, stop+1):
- result = pad(num * x, 3)
- print(f' {pad(num)} x {pad(x)} = {result}')
- print('')
- def gen_title(num):
- title = f' times table: {pad(num)} '
- border = '#' * len(title)
- return title.upper() + f'\n{border}'
- def pad(num, zeros=2):
- snum = str(num).zfill(zeros)
- return snum
- if __name__ == '__main__':
- gen_table(range(1, 13))
- gen_table([14])
Add Comment
Please, Sign In to add comment