ellesehc

Simple Calculator(Prototype)

Sep 20th, 2014
387
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.96 KB | None | 0 0
  1. def home():
  2.     print "Welcome! Please enter the function you desire: "
  3.     function = raw_input()
  4.     if function == '+':
  5.         return add()
  6.     if function == "/":
  7.         return div()
  8.     if function == "*":
  9.         return mul()
  10.     if function == "-":
  11.         return sub()
  12.     else:
  13.         print "Invalid character"
  14.     return home()
  15.  
  16. def add():
  17.     print "Enter 1st number"
  18.     a = int(raw_input())
  19.     print "Enter 2nd number"
  20.     b = int(raw_input())
  21.     c = a + b
  22.     print "The sum is",c
  23.     return home()
  24.  
  25. def div():
  26.     print "Enter 1st number"
  27.     a = float(raw_input())
  28.     print "Enter 2nd number"
  29.     b = float(raw_input())
  30.     c = a / b
  31.     print "The quotient is", (c)
  32.     return home()
  33.  
  34. def mul():
  35.     print "Enter 1st number"
  36.     a = int(raw_input())
  37.     print "Enter 2nd number"
  38.     b = int(raw_input())
  39.     c = a * b
  40.     print "The product is", c
  41.     return home()
  42.  
  43. def sub():
  44.     print "Enter 1st number"
  45.     a = int(raw_input())
  46.     print "Enter 2nd number"
  47.     b = int(raw_input())
  48.     c = a - b
  49.     print "The difference is", c
  50.     return home()
Advertisement
Add Comment
Please, Sign In to add comment