faddai

Multiplication Table

Apr 12th, 2013
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.00 KB | None | 0 0
  1. """ A multiplication table for persons of certain ages"""
  2.  
  3. age = input("Please enter your age... ")
  4.  
  5. """Persons 4years of age or younger and not younger than a year.
  6. - display multiplication tables for 4,5,6
  7. For persons 18years and above but not older than 21
  8. - display a multiplication table for 7, 8, 9
  9. For any other age, there is no multiplication table available
  10. for viewing
  11. """
  12.  
  13. if age <= 4 and age >= 1:
  14.     for multiplier in [4, 5, 6]:
  15.         print " "
  16.         print "MULTIPLICATION TABLE FOR {0}".format(multiplier)
  17.         print "----------------------------"
  18.         for i in range(1, 13):
  19.             print "{0} x {1} = {2}".format( multiplier, i, multiplier * i )
  20. elif age >= 18 and age <= 21:
  21.     for multiplier in [7, 8, 9]:
  22.         print " "
  23.         print "MULTIPLICATION TABLE FOR {0}".format(multiplier)
  24.         print "----------------------------"
  25.         for i in range(1, 13):
  26.             print "{0} x {1} = {2}".format( multiplier, i, multiplier * i )    
  27. else:
  28.     print "\nSorry, there is no multiplication table available for the specified age.\n"
Advertisement
Add Comment
Please, Sign In to add comment