WK6

.docx

School

American Military University *

*We aren’t endorsed by this school

Course

220

Subject

Computer Science

Date

Feb 20, 2024

Type

docx

Pages

5

Uploaded by ChefSnow3329

Report
ASSIGNMENT: You are going to enhance the prior assignment by doing the following. Use list to create a menu (NOT in the library) Add a function to the library that will return the results of the four operations in a dictionary object allInOne(n1, n2) #Wk6.py #Student Name: #Course: ENTD220 #Instructor: Dr. Meadors #Date: 20240210 #Copy Wrong: This is my work import Wk6_Mylib as Mylib def main(): try: lowRange = float(input("Enter your low range:")) highRange = float(input("Enter your high range:")) n1 = float(input('Enter your first number:')) n2 = float(input('Enter your second number:')) lr = lowRange hr = highRange n1, n2 = Mylib.isinrange(lr, hr, n1, n2) except ValueError: print("You must enter a number") else:
calclist = ["1) Add", "2) Subtract", "3) Multiply", "4) Divides", "5) Scalc", "6) All in one"] # printing list for user for item in calclist: print(item) # gathering input for menu selection menuinput = int(input("Enter your choice: ")) # if then to use menu input and run correct functions # utilizing many function from library including scalc and dictionary forallinone # finally an else statement to check for valid input if menuinput == 1: print(n1,'+',n2,'=',Mylib.add(n1,n2)) elif menuinput == 2: print(n1,'-',n2,'=',Mylib.sub(n1,n2)) elif menuinput == 3: print(n1,'*',n2,'=',Mylib.mult(n1,n2)) elif menuinput == 4: print(n1,'/',n2,'=',Mylib.div(n1,n2)) elif menuinput == 5: operator = input("Please choose an opperation [ + - * / ] ") result_scalc = Mylib.scalc(f"{n1},{n2}", operator) print(result_scalc) elif menuinput == 6:
Mylib.AllinOne(n1,n2) else: print("Please enter a valid input!") #Prompt to loop back to beginning. question = str(input("Do you want to do more calculations? Enter 'yes' or 'no':")) if question.lower() == "yes": main() elif question.lower() == "no": print("Thank you and have a great day! :-)") else: quit() main() ################################################## ######################### #Wk6_Mylib.py #Student Name: #Course: ENTD220 #Instructor: Dr. Meadors #Date: 20240210 #Copy Wrong: This is my work def add(n1,n2): return n1 + n2 def mult(n1,n2): return n1 * n2 def sub(n1,n2):
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help