Advertisement
SirChimi

MultiplicationTable.py

Aug 14th, 2014
528
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.33 KB | None | 0 0
  1. mx = raw_input("Enter a max value: ") #prompt for max for x and y
  2. xy = range(1,int(mx) + 1) #make list 1 - max
  3.  
  4. def sp(n): #determine num spaces
  5.     if n < 10: return 3
  6.     elif n < 100: return 2
  7.     else: return 1
  8.  
  9. for x in xy: #iterate 1-max * 1-max
  10.     for y in xy:
  11.         print str(x * y) + " " * sp(x * y),
  12.     print
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement