Skip to content

Instantly share code, notes, and snippets.

@l3robot
Last active June 25, 2016 16:02
Show Gist options
  • Select an option

  • Save l3robot/9ce05487aa65e1249b6346c410aab826 to your computer and use it in GitHub Desktop.

Select an option

Save l3robot/9ce05487aa65e1249b6346c410aab826 to your computer and use it in GitHub Desktop.
create a table of multipllication
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