Lab description:
Similar to Lab 2 except that functions are used to compute the numbers.
Code:
userinput = input ("Choose an option: \n(1) sum numbers \n(2) subtract numbers \n(3) multiply numbers \n(4) divide numbers \n(5) remainder of numbers \n(6) compare numbers \n(7) exit\n") while userinput == 1: print ("sum numbers") sumnumberx = input ("choose your x value: ") sumnumbery = input ("choose your y value: ") float (sumnumberx) float (sumnumbery) def sumnumbers (sumnumberx, sumnumbery): return sumnumberx + sumnumbery print (sumnumbers(sumnumberx, sumnumbery)) startover = input ("would you like to start over? \n(11) yes\n(12) no\n") if startover == 11: userinput = input ("Choose an option: \n(1) sum numbers \n(2) subtract numbers \n(3) multiply numbers \n(4) divide numbers \n(5) remainder of numbers \n(6) compare numbers \n(7) exit\n") elif startover != 11: userinput = 7 while userinput == 2: print ("subtract numbers") subnumberx = input ("choose your x value: ") subnumbery = input ("choose your y value: ") float (subnumberx) float (subnumbery) def subnumbers (subnumberx, subnumbery): return subnumberx - subnumbery print (subnumbers(subnumberx, subnumbery)) startover = input ("would you like to start over? \n(11) yes\n(12) no\n") if startover == 11: userinput = input ("Choose an option: \n(1) sum numbers \n(2) subtract numbers \n(3) multiply numbers \n(4) divide numbers \n(5) remainder of numbers \n(6) compare numbers \n(7) exit\n") elif startover != 11: userinput = 7 while userinput ==3: print ("multiply numbers") mulnumberx = input ("choose your x value: ") mulnumbery = input ("choose your y value: ") float (mulnumberx) float (mulnumbery) def mulnumbers (mulnumberx, mulnumbery): return mulnumberx * mulnumbery print (mulnumbers(mulnumberx, mulnumbery)) startover = input ("would you like to start over? \n(11) yes\n(12) no\n") if startover == 11: userinput = input ("Choose an option: \n(1) sum numbers \n(2) subtract numbers \n(3) multiply numbers \n(4) divide numbers \n(5) remainder of numbers \n(6) compare numbers \n(7) exit\n") elif startover != 11: userinput = 7 while userinput ==4: print ("divide numbers") divnumberx = input ("choose your x value: ") divnumbery = input ("choose your y value: ") float (divnumberx) float (divnumbery) def divnumbers (divnumberx, divnumbery): return divnumberx / divnumbery print (divnumbers(divnumberx, divnumbery)) startover = input ("would you like to start over? \n(11) yes\n(12) no\n") if startover == 11: userinput = input ("Choose an option: \n(1) sum numbers \n(2) subtract numbers \n(3) multiply numbers \n(4) divide numbers \n(5) remainder of numbers \n(6) compare numbers \n(7) exit\n") elif startover != 11: userinput = 7 while userinput ==5: print ("remainder of numbers") remnumberx = input ("choose your x value: ") remnumbery = input ("choose your y value: ") float (remnumberx) float (remnumbery) def remnumbers (remnumberx, remnumbery): return remnumberx % remnumbery print (remnumbers(remnumberx, remnumbery)) startover = input ("would you like to start over? \n(11) yes\n(12) no\n") if startover == 11: userinput = input ("Choose an option: \n(1) sum numbers \n(2) subtract numbers \n(3) multiply numbers \n(4) divide numbers \n(5) remainder of numbers \n(6) compare numbers \n(7) exit\n") elif startover != 11: userinput = 7 while userinput ==6: import math print ("compare numbers") comnumberx = input ("choose your x value: ") comnumbery = input ("choose your y value: ") float (comnumberx) float (comnumbery) def comnumbers (comnumberx, comnumbery): return comnumberx - comnumbery print (abs(comnumbers(comnumberx, comnumbery))) startover = input ("would you like to start over? \n(11) yes\n(12) no\n") if startover == 11: userinput = input ("Choose an option: \n(1) sum numbers \n(2) subtract numbers \n(3) multiply numbers \n(4) divide numbers \n(5) remainder of numbers \n(6) compare numbers \n(7) exit\n") elif startover != 11: userinput = 7