Advertisement
Guest User

unvar god tier calculator

a guest
Aug 23rd, 2014
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 8.21 KB | None | 0 0
  1. import time
  2.  
  3.  
  4. print "###############################################################################"
  5. print "####################+++Unvarying's Calculator+++###############################"
  6. print "###############################################################################\n"
  7.  
  8.  
  9. def dm_addition(n1, n2):
  10.     add = n1 + n2
  11.     return add
  12.    
  13. def dm_subtraction(n1, n2):
  14.     subtract = n1 - n2
  15.     return subtract
  16.  
  17. def dm_multiplication(n1, n2):
  18.     multiply = n1 * n2
  19.     return multiply
  20.  
  21. def dm_division(n1, n2):
  22.     divide = n1 / n2
  23.     return divide
  24. def calc():
  25.  
  26.  
  27.  
  28.     print "Which operation would you like to perform?"
  29.  
  30.  
  31.     while True:
  32.         print "Operations are +, -, *, or /. Please enter operation below."
  33.        
  34.         opq = raw_input()
  35.        
  36.         if opq == "+":
  37.             print "Addition selected!"
  38.             while True:
  39.                 fq = raw_input("Would you like to have more than 2 numbers in this operation? (y/n): ")
  40.                 amount = []
  41.                 if fq == "y" or fq == "Y":
  42.                     while True:
  43.                         a = raw_input("How many numbers would you like to have in this operation? ")
  44.                                    
  45.                         if a == "1":
  46.                             print "Error! Must be more than 2 numbers!"
  47.                             continue
  48.                                        
  49.                         elif a == "2":
  50.                             print "Error! Must be more than 2 numbers!"
  51.                                    
  52.                    
  53.                         else: break
  54.  
  55.                     print "Appended!"
  56.                     print "Please enter the "+a+" numbers you would like to add below:"
  57.                                
  58.                     for x in range(0, + int(a)):
  59.                         x = int(raw_input(""))
  60.                         amount.append(x)
  61.                                        
  62.                     print "\nAppended!"
  63.                                
  64.                     do_math = sum(amount)
  65.                                
  66.                     x = str(do_math)
  67.                    
  68.                     print "\nAnswer: "+x+"\n"
  69.                        
  70.                     while True:
  71.                         x_2 = raw_input("Would you like to continue using this calculator? (y/n) ")
  72.            
  73.                         if x_2 == "n" or x_2 == "N":
  74.                             quit()
  75.                         elif x_2 == "y" or x_2 == "Y":
  76.                             return calc()  
  77.                            
  78.                            
  79.                 elif fq == "n" or fq == "N":
  80.                     break
  81.                                
  82.                 else:
  83.                     print "Error! Answer must be Y or N!"
  84.                     continue
  85.                        
  86.            
  87.             n1 = int(raw_input("What will be the first number?: "))
  88.             n2 = int(raw_input("What will be the second number?: "))
  89.             time.sleep(0.2)
  90.             print "Appended!"
  91.             time.sleep(0.2)
  92.             a = dm_addition(n1, n2)
  93.             print "Answer: %s" % (a)
  94.             time.sleep(0.2)
  95.             while True:
  96.                 qq = raw_input("Would you like to quit? (y/n)")
  97.                 if qq == "y" or qq == "Y":
  98.                     quit()
  99.                 elif qq == "n" or qq == "N":
  100.                     print "Which operation would you like to perform?"
  101.                     break
  102.                 else:
  103.                     print "Error, please enter Y or N"
  104.                     continue
  105.                
  106.         elif opq == "-":
  107.             print "Subtraction selected!"
  108.             while True:
  109.                     fq = raw_input("Would you like to have more than 2 numbers in this operation? (y/n): ")
  110.                     amount = []
  111.                     if fq == "y" or fq == "Y":
  112.                         while True:
  113.                             a = raw_input("How many numbers would you like to have in this operation? ")
  114.                                        
  115.                             if a == "1":
  116.                                 print "Error! Must be more than 2 numbers!"
  117.                                 continue
  118.                                            
  119.                             elif a == "2":
  120.                                 print "Error! Must be more than 2 numbers!"
  121.                                        
  122.                        
  123.                             else: break
  124.  
  125.                         print "Appended!"
  126.                         print "Please enter the "+a+" numbers you would like to subtract below:"
  127.                                    
  128.                         for x in range(0, + int(a)):
  129.                             x = int(raw_input(""))
  130.                             amount.append(x)
  131.                                            
  132.                         print "\nAppended!"
  133.                                    
  134.                         do_math = reduce(lambda x, y: x-y, (amount))
  135.                                    
  136.                         x = str(do_math)
  137.                        
  138.                         print "\nAnswer: "+x+"\n"
  139.                            
  140.                         while True:
  141.                             x_2 = raw_input("Would you like to continue using this calculator? (y/n) ")
  142.                
  143.                             if x_2 == "n" or x_2 == "N":
  144.                                 quit()
  145.                             elif x_2 == "y" or x_2 == "Y":
  146.                                 return calc()  
  147.                                
  148.                                
  149.                     elif fq == "n" or fq == "N":
  150.                         break
  151.                                    
  152.                     else:
  153.                         print "Error! Answer must be Y or N!"
  154.                         continue
  155.                        
  156.             n1 = int(raw_input("What will be the first number?: "))
  157.             n2 = int(raw_input("What will be the second number?: "))
  158.             time.sleep(0.2)
  159.             print "Appended!"
  160.             time.sleep(0.2)
  161.             a = dm_subtraction(n1, n2)
  162.             print "Answer: %s" % (a)
  163.             time.sleep(0.2)
  164.             while True:
  165.                 qq = raw_input("Would you like to quit? (y/n)")
  166.                 if qq == "y" or qq == "Y":
  167.                     quit()
  168.                 elif qq == "n" or qq == "N":
  169.                     print "Which operation would you like to perform?"
  170.                     break
  171.                 else:
  172.                     print "Error, please enter Y or N"
  173.                     continue
  174.         elif opq == "*":
  175.                 print "Multiplication selected!"
  176.                 while True:
  177.                     fq = raw_input("Would you like to have more than 2 numbers in this operation? (y/n): ")
  178.                     amount = []
  179.                     if fq == "y" or fq == "Y":
  180.                         while True:
  181.                             a = raw_input("How many numbers would you like to have in this operation? ")
  182.                                        
  183.                             if a == "1":
  184.                                 print "Error! Must be more than 2 numbers!"
  185.                                 continue
  186.                                            
  187.                             elif a == "2":
  188.                                 print "Error! Must be more than 2 numbers!"
  189.                                        
  190.                        
  191.                             else: break
  192.  
  193.                         print "Appended!"
  194.                         print "Please enter the "+a+" numbers you would like to multiply below:"
  195.                                    
  196.                         for x in range(0, + int(a)):
  197.                             x = int(raw_input(""))
  198.                             amount.append(x)
  199.                                            
  200.                         print "\nAppended!"
  201.                                    
  202.                         do_math = reduce(lambda x, y: x*y, (amount))
  203.                                    
  204.                         x = str(do_math)
  205.                        
  206.                         print "\nAnswer: "+x+"\n"
  207.                            
  208.                         while True:
  209.                             x_2 = raw_input("Would you like to continue using this calculator? (y/n) ")
  210.                
  211.                             if x_2 == "n" or x_2 == "N":
  212.                                 quit()
  213.                             elif x_2 == "y" or x_2 == "Y":
  214.                                 return calc()  
  215.                                
  216.                                
  217.                     elif fq == "n" or fq == "N":
  218.                         break
  219.                                    
  220.                     else:
  221.                         print "Error! Answer must be Y or N!"
  222.                         continue
  223.                        
  224.                 n1 = int(raw_input("What will be the first number?: "))
  225.                 n2 = int(raw_input("What will be the second number?: "))
  226.                 time.sleep(0.2)
  227.                 print "Appended!"
  228.                 time.sleep(0.2)
  229.                 a = dm_multiplication(n1, n2)
  230.                 print "Answer: %s" % (a)
  231.                 time.sleep(0.2)
  232.                 while True:
  233.                     qq = raw_input("Would you like to quit? (y/n)")
  234.                     if qq == "y" or qq == "Y":
  235.                         quit()
  236.                     elif qq == "n" or qq == "N":
  237.                         print "Which operation would you like to perform?"
  238.                         break
  239.                     else:
  240.                         print "Error, please enter Y or N"
  241.                         continue
  242.                    
  243.         elif opq == "/":
  244.                 print "Division selected!"
  245.                 while True:
  246.                     fq = raw_input("Would you like to have more than 2 numbers in this operation? (y/n): ")
  247.                     amount = []
  248.                     if fq == "y" or fq == "Y":
  249.                         while True:
  250.                             a = raw_input("How many numbers would you like to have in this operation? ")
  251.                                        
  252.                             if a == "1":
  253.                                 print "Error! Must be more than 2 numbers!"
  254.                                 continue
  255.                                            
  256.                             elif a == "2":
  257.                                 print "Error! Must be more than 2 numbers!"
  258.                                        
  259.                        
  260.                             else: break
  261.  
  262.                         print "Appended!"
  263.                         print "Please enter the "+a+" numbers you would like to divide below:"
  264.                                    
  265.                         for x in range(0, + int(a)):
  266.                             x = int(raw_input(""))
  267.                             amount.append(x)
  268.                                            
  269.                         print "\nAppended!"
  270.                                    
  271.                         do_math = reduce(lambda x, y: x/y, (amount))
  272.                                    
  273.                         x = str(do_math)
  274.                        
  275.                         print "\nAnswer: "+x+"\n"
  276.                            
  277.                         while True:
  278.                             x_2 = raw_input("Would you like to continue using this calculator? (y/n) ")
  279.                
  280.                             if x_2 == "n" or x_2 == "N":
  281.                                 quit()
  282.                             elif x_2 == "y" or x_2 == "Y":
  283.                                 return calc()  
  284.                                
  285.                                
  286.                     elif fq == "n" or fq == "N":
  287.                         break
  288.                                    
  289.                     else:
  290.                         print "Error! Answer must be Y or N!"
  291.                         continue
  292.                        
  293.                 n1 = int(raw_input("What will be the first number?: "))
  294.                 n2 = int(raw_input("What will be the second number?: "))
  295.                 time.sleep(0.2)
  296.                 print "Appended!"
  297.                 time.sleep(0.2)
  298.                 a = dm_division(n1, n2)
  299.                 print "Answer: %s" % (a)
  300.                 time.sleep(0.2)
  301.                 while True:
  302.                     qq = raw_input("Would you like to quit? (y/n)")
  303.                     if qq == "y" or qq == "Y":
  304.                         quit()
  305.                     elif qq == "n" or qq == "N":
  306.                         print "Which operation would you like to perform?"
  307.                         break
  308.                     else:
  309.                         print "Error, please enter Y or N"
  310.                         continue
  311.        
  312.            
  313.         else:
  314.             print "Error! Invalid operation selected! Please choose an operation from the list >>> +, -, *, or /."
  315.             continue
  316.            
  317.     quit()
  318. calc()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement