Last active
June 25, 2016 16:02
-
-
Save l3robot/9ce05487aa65e1249b6346c410aab826 to your computer and use it in GitHub Desktop.
create a table of multipllication
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 sys | |
| import os | |
| def create_table(n, m): | |
| print(' ========================') | |
| print(' || TABLE OF {:<4d} || '.format(n)) | |
| print(' ||====================||') | |
| for mm in range(m): | |
| p = n * mm | |
| print(' || {:4d} x {:<4d} | {:4d} ||'.format(n, mm, p)) | |
| print(' ||____________________||') | |
| if __name__ == "__main__": | |
| if len(sys.argv) < 3: | |
| print(' [ ! ] You have to give a number and a maximum multiplicator') | |
| exit() | |
| try: | |
| n = int(sys.argv[1]) | |
| except ValueError: | |
| print(' [ ! ] You gave a wrong number, must be an int') | |
| exit() | |
| try: | |
| m = int(sys.argv[2]) | |
| except ValueError: | |
| print(' [ ! ] You gave a wrong multiplicator, must be an int') | |
| exit() | |
| create_table(n, m) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment