Advertisement
rfmonk

calculator.py

Jul 30th, 2014
326
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.92 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3.  
  4. print("Welcome to Calculator v1.1")
  5. print("     A)Addition")
  6. print("     B)Subtraction")
  7. print("     C)Multiplication")
  8. print("     D)Division")
  9. print("     E)Press Enter to Exit")
  10.  
  11. choice = raw_input("Pick your calculation:   ")
  12.  
  13. Loop = "True"
  14.  
  15. while True:
  16.     if choice == "A":
  17.         X = input("Enter the first number:  ")
  18.         Y = input("Enter the second number: ")
  19.         print("Your answer is:   " + str(X+Y))
  20.        
  21.         print("     A)Addition")
  22.         print("     B)Subtraction")
  23.         print("     C)Multiplication")
  24.         print("     D)Division")
  25.         print("     E)Press Enter to Exit")
  26.         choice = raw_input("Pick your calculation:  ")
  27.  
  28.     if choice == "B":
  29.         X = input("Enter the first number:  ")
  30.         Y = input("Enter the second number: ")
  31.         print("Your answer is:   " + str(X-Y))
  32.        
  33.         print("     A)Addition")
  34.         print("     B)Subtraction")
  35.         print("     C)Multiplication")
  36.         print("     D)Division")
  37.         print("     E)Press Enter to Exit")
  38.         choice = raw_input("Pick your calculation:  ")
  39.  
  40.     if choice == "C":
  41.         X = input("Enter the first number:  ")
  42.         Y = input("Enter the second number: ")
  43.         print("Your answer is:   " + str(X*Y))
  44.        
  45.         print("     A)Addition")
  46.         print("     B)Subtraction")
  47.         print("     C)Multiplication")
  48.         print("     D)Division")
  49.         print("     E)Press Enter to Exit")
  50.         choice = raw_input("Pick your calculation:  ")
  51.  
  52.     if choice == "D":
  53.         X = input("Enter the first number:  ")
  54.         Y = input("Enter the second number: ")
  55.         print("Your answer is:   " + str(X/Y))
  56.        
  57.         print("     A)Addition")
  58.         print("     B)Subtraction")
  59.         print("     C)Multiplication")
  60.         print("     D)Division")
  61.         print("     E)Press Enter to Exit")
  62.         choice = raw_input("Pick your calculation:  ")
  63.  
  64.     if choice == "E":
  65.         break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement