Last active
August 3, 2018 15:37
-
-
Save ScriptAutomate/3960bf7af4cfa514dc9021131ec518c3 to your computer and use it in GitHub Desktop.
Multiplication Table Generator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
""" | |
Creates multiplication tables | |
""" | |
def get_arguments(): | |
parser = argparse.ArgumentParser( | |
formatter_class=argparse.ArgumentDefaultsHelpFormatter, | |
description="%(prog)s is a tool for generating a \ | |
multiplication table for a provided number, along with \ | |
a multiple." | |
) | |
parser.add_argument('base_num', | |
help='Number to create multiplication table for', | |
type=float) | |
parser.add_argument('multiple', | |
help='Up to which multiple', | |
type=int) | |
args = parser.parse_args() | |
return args.base_num, args.multiple | |
def multi_table(base_num, multiple): | |
for i in range(1, multiple+1): | |
print(f'{base_num} x {i} = {base_num*i}') | |
if __name__ == '__main__': | |
base_num, multiple = get_arguments() | |
multi_table(base_num, multiple) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment