SlideShare a Scribd company logo
1 of 7
Mylib.py
def allInOne(n1, n2):
return {"add":plus(n1, n2),
"sub":subtract(n1, n2),
"mult":multiply(n1, n2),
"div": divide(n1, n2)}
def IsInRange(lr, hr, n):
return lr < n and n < hr
#add 2 numbers
def plus(n1,n2):
add = n1 + n2
return add
#subtract 2 numbers
def subtract(n1, n2):
sub = n1 - n2
return sub
#multiply 2 numbers
def multiply(n1, n2):
mult = n1 * n2
return mult
#division, n2 should not be zero
def divide(n1, n2):
try:
div = n1/(n2 + 0.0)
return div
except ZeroDivisionError as e:
print("The result of %s/%s = %s" % (n1, n2,"You cannot
divide by Zero"))
except Exception :
print("Invalid input" , n1, n2)
#expression calculator
def scalc(val):
try:
#the epression is assumed to be comma separated
ns = val.split(",")
#split it into 3 parts
#remove whitespaces in the components
n1 = int(ns[0].strip())
n2 = int(ns[1].strip())
op = ns[2].strip()
#check if operator is one of the supported
if op == "*":
return multiply(n1, n2)
elif op == "/":
return divide(n1, n2)
elif op == "+":
return plus(n1, n2)
elif op == "-":
return subtract(n1, n2)
else:
print("Unknown operator", op)
#in case of invalid input catch the error
except Exception :
print("Invalid input:" , val)
W6_first_last.py
# Program name :
# Student Name :
# Course : ENTD220
# Instructor :
# Date : 02/12/2020
# Description : Expression & Arithmetic Calculator
# Copy Wrong : This is my work
import Mylib
def doScalc():
print("---------Expression calculator------------------")
print("Enter the expression with format N1,N2,operator:")
print("Supported operator * , /, -, +")
print("E.g 5, 4, *)")
val = input()
res = Mylib.scalc(val)
print('The result of "' + val + '" is', res)
def showList():
print("1) Add two numbers")
print("2) Multiply two numbers")
print("3) Subtract two numbers")
print("4) Divide two numbers")
print("5) Scalc")
print("6) All in one")
print("7) Exit")
def getUserInput():
low = int(input("Enter Lower range:"))
high = int(input("Enter Higher range:"))
n1 = int(input("Enter first number:"))
n2 = int(input("Enter second number:"))
return [low, high, n1 , n2]
def doCalculation(op):
user = getUserInput()
low = user[0]
high = user[1]
n1 = user[2]
n2 = user[3]
if Mylib.IsInRange(low , high, n1) and 
Mylib.IsInRange(low , high, n2):
if op == "+":
res = Mylib.plus(n1, n2)
elif op == "*":
res = Mylib.multiply(n1, n2)
elif op == "-":
res = Mylib.subtract(n1, n2)
elif op == "/":
res = Mylib.divide(n1, n2)
print("%d %s %d = %d" % (n1, op, n2, res))
else:
print("Error: input out of range")
def doAllInOne():
user = getUserInput()
low = user[0]
high = user[1]
n1 = user[2]
n2 = user[3]
if Mylib.IsInRange(low , high, n1) and 
Mylib.IsInRange(low , high, n2):
mydict = Mylib.allInOne(n1, n2)
print("%d + %d = %d" % (n1, n2, mydict["add"]))
print("%d - %d = %d" % (n1, n2, mydict["sub"]))
print("%d * %d = %d" % (n1, n2, mydict["mult"]))
print("%d / %d = %d" % (n1, n2, mydict["div"]))
def main():
while True:
showList()
action = int(input("What do you want to do?"))
if action == 7:
break;
if action == 1:
user = getUserInput
doCalculation("+")
elif action == 2:
doCalculation("*")
elif action == 3:
doCalculation("-")
elif action == 4:
doCalculation("/")
elif action == 5:
doScalc()
elif action == 6:
doAllInOne()
print()
main()
print("Thanks for using our calculator!")

More Related Content

Similar to Mylib.pydef allInOne(n1, n2) return {addplus(n1, n2.docx

Implement the following sorting algorithms Bubble Sort Insertion S.pdf
Implement the following sorting algorithms  Bubble Sort  Insertion S.pdfImplement the following sorting algorithms  Bubble Sort  Insertion S.pdf
Implement the following sorting algorithms Bubble Sort Insertion S.pdf
kesav24
 
C programs
C programsC programs
C programs
Minu S
 

Similar to Mylib.pydef allInOne(n1, n2) return {addplus(n1, n2.docx (20)

Practicle 1.docx
Practicle 1.docxPracticle 1.docx
Practicle 1.docx
 
Basic python programs
Basic python programsBasic python programs
Basic python programs
 
Python Tidbits
Python TidbitsPython Tidbits
Python Tidbits
 
Practical File waale code.pdf
Practical File waale code.pdfPractical File waale code.pdf
Practical File waale code.pdf
 
Programs.doc
Programs.docPrograms.doc
Programs.doc
 
AI-Programs.pdf
AI-Programs.pdfAI-Programs.pdf
AI-Programs.pdf
 
Python From Scratch (1).pdf
Python From Scratch  (1).pdfPython From Scratch  (1).pdf
Python From Scratch (1).pdf
 
fds Practicle 1to 6 program.pdf
fds Practicle 1to 6 program.pdffds Practicle 1to 6 program.pdf
fds Practicle 1to 6 program.pdf
 
Matlab project
Matlab projectMatlab project
Matlab project
 
L25-L26-Parameter passing techniques.pptx
L25-L26-Parameter passing techniques.pptxL25-L26-Parameter passing techniques.pptx
L25-L26-Parameter passing techniques.pptx
 
ECE-PYTHON.docx
ECE-PYTHON.docxECE-PYTHON.docx
ECE-PYTHON.docx
 
Functional Programming with Groovy
Functional Programming with GroovyFunctional Programming with Groovy
Functional Programming with Groovy
 
Implement the following sorting algorithms Bubble Sort Insertion S.pdf
Implement the following sorting algorithms  Bubble Sort  Insertion S.pdfImplement the following sorting algorithms  Bubble Sort  Insertion S.pdf
Implement the following sorting algorithms Bubble Sort Insertion S.pdf
 
xii cs practicals
xii cs practicalsxii cs practicals
xii cs practicals
 
hotelmangt project code connecting python wih Mysql cbse 2022-23 project .docx
hotelmangt project code connecting python wih Mysql cbse 2022-23 project .docxhotelmangt project code connecting python wih Mysql cbse 2022-23 project .docx
hotelmangt project code connecting python wih Mysql cbse 2022-23 project .docx
 
DSP LAB COMPLETE CODES.docx
DSP LAB COMPLETE CODES.docxDSP LAB COMPLETE CODES.docx
DSP LAB COMPLETE CODES.docx
 
Retos de Programación en Python
Retos de Programación en PythonRetos de Programación en Python
Retos de Programación en Python
 
C programs
C programsC programs
C programs
 
DataStructures notes
DataStructures notesDataStructures notes
DataStructures notes
 
Swift 5.1 Language Guide Notes.pdf
Swift 5.1 Language Guide Notes.pdfSwift 5.1 Language Guide Notes.pdf
Swift 5.1 Language Guide Notes.pdf
 

More from gemaherd

Need a reply 1Amy Simons is an aunt to my mum. Amy passed on.docx
Need a reply 1Amy Simons is an aunt to my mum. Amy passed on.docxNeed a reply 1Amy Simons is an aunt to my mum. Amy passed on.docx
Need a reply 1Amy Simons is an aunt to my mum. Amy passed on.docx
gemaherd
 
Need a one response for each discussion post in 50 to 75 words.docx
Need a one response for each discussion post in 50 to 75 words.docxNeed a one response for each discussion post in 50 to 75 words.docx
Need a one response for each discussion post in 50 to 75 words.docx
gemaherd
 
Nazi GermanyBrenda Thomas LaShuntae JacksonThe R.docx
Nazi GermanyBrenda Thomas LaShuntae JacksonThe R.docxNazi GermanyBrenda Thomas LaShuntae JacksonThe R.docx
Nazi GermanyBrenda Thomas LaShuntae JacksonThe R.docx
gemaherd
 
Nature GeNetics  VOLUME 46 NUMBER 10 OCTOBER 2014 1 0 8 9.docx
Nature GeNetics  VOLUME 46  NUMBER 10  OCTOBER 2014 1 0 8 9.docxNature GeNetics  VOLUME 46  NUMBER 10  OCTOBER 2014 1 0 8 9.docx
Nature GeNetics  VOLUME 46 NUMBER 10 OCTOBER 2014 1 0 8 9.docx
gemaherd
 
Nature VS NurtureResearch writing 310Joi Tucker.docx
Nature VS NurtureResearch writing 310Joi Tucker.docxNature VS NurtureResearch writing 310Joi Tucker.docx
Nature VS NurtureResearch writing 310Joi Tucker.docx
gemaherd
 

More from gemaherd (20)

Natural Selection and Patterns of Evolution WorksheetComplet.docx
Natural Selection and Patterns of Evolution WorksheetComplet.docxNatural Selection and Patterns of Evolution WorksheetComplet.docx
Natural Selection and Patterns of Evolution WorksheetComplet.docx
 
Navigate to the Pearson Assessment website. Identify an assessme.docx
Navigate to the Pearson Assessment website. Identify an assessme.docxNavigate to the Pearson Assessment website. Identify an assessme.docx
Navigate to the Pearson Assessment website. Identify an assessme.docx
 
Need a reply 1Amy Simons is an aunt to my mum. Amy passed on.docx
Need a reply 1Amy Simons is an aunt to my mum. Amy passed on.docxNeed a reply 1Amy Simons is an aunt to my mum. Amy passed on.docx
Need a reply 1Amy Simons is an aunt to my mum. Amy passed on.docx
 
Need a PowerPoint 12 pages on the following nursing theory   Peacefu.docx
Need a PowerPoint 12 pages on the following nursing theory   Peacefu.docxNeed a PowerPoint 12 pages on the following nursing theory   Peacefu.docx
Need a PowerPoint 12 pages on the following nursing theory   Peacefu.docx
 
Need 5 papers along with reference page Topic Delay in Phys.docx
Need 5 papers along with reference page Topic Delay in Phys.docxNeed 5 papers along with reference page Topic Delay in Phys.docx
Need 5 papers along with reference page Topic Delay in Phys.docx
 
Need 6 pages with APA format and referencesThere are several e.docx
Need 6 pages with APA format and referencesThere are several e.docxNeed 6 pages with APA format and referencesThere are several e.docx
Need 6 pages with APA format and referencesThere are several e.docx
 
need a research paper about leadership in 10 pages with 10 reference.docx
need a research paper about leadership in 10 pages with 10 reference.docxneed a research paper about leadership in 10 pages with 10 reference.docx
need a research paper about leadership in 10 pages with 10 reference.docx
 
Need a QUALITATIVE Journal, The topic is up to you as long as yo.docx
Need a QUALITATIVE Journal, The topic is up to you as long as yo.docxNeed a QUALITATIVE Journal, The topic is up to you as long as yo.docx
Need a QUALITATIVE Journal, The topic is up to you as long as yo.docx
 
Need a one response for each discussion post in 50 to 75 words.docx
Need a one response for each discussion post in 50 to 75 words.docxNeed a one response for each discussion post in 50 to 75 words.docx
Need a one response for each discussion post in 50 to 75 words.docx
 
Need 20 -25 pages Identify the key problems and issues in .docx
Need 20 -25 pages Identify the key problems and issues in .docxNeed 20 -25 pages Identify the key problems and issues in .docx
Need 20 -25 pages Identify the key problems and issues in .docx
 
Need a research paper with ANY ONE of the below topicsT.docx
Need a research paper with ANY ONE of the below topicsT.docxNeed a research paper with ANY ONE of the below topicsT.docx
Need a research paper with ANY ONE of the below topicsT.docx
 
Necesito un essay en espanolTema   Explique algunas de las inst.docx
Necesito un essay en espanolTema   Explique algunas de las inst.docxNecesito un essay en espanolTema   Explique algunas de las inst.docx
Necesito un essay en espanolTema   Explique algunas de las inst.docx
 
Need 400 wordsBy October of 2017, Yahoo estimated that 3 billion.docx
Need 400 wordsBy October of 2017, Yahoo estimated that 3 billion.docxNeed 400 wordsBy October of 2017, Yahoo estimated that 3 billion.docx
Need 400 wordsBy October of 2017, Yahoo estimated that 3 billion.docx
 
Need 1500 words  Dissertationresearch method on the impact of C.docx
Need 1500 words  Dissertationresearch method on the impact of C.docxNeed 1500 words  Dissertationresearch method on the impact of C.docx
Need 1500 words  Dissertationresearch method on the impact of C.docx
 
Need 250 words Initial Post and two replies of 100 words each. Will .docx
Need 250 words Initial Post and two replies of 100 words each. Will .docxNeed 250 words Initial Post and two replies of 100 words each. Will .docx
Need 250 words Initial Post and two replies of 100 words each. Will .docx
 
Nazi GermanyBrenda Thomas LaShuntae JacksonThe R.docx
Nazi GermanyBrenda Thomas LaShuntae JacksonThe R.docxNazi GermanyBrenda Thomas LaShuntae JacksonThe R.docx
Nazi GermanyBrenda Thomas LaShuntae JacksonThe R.docx
 
Need a paper with atleast 1000 - 1200 words.you can find the del.docx
Need a paper with atleast 1000 - 1200 words.you can find the del.docxNeed a paper with atleast 1000 - 1200 words.you can find the del.docx
Need a paper with atleast 1000 - 1200 words.you can find the del.docx
 
Necesito un Essay en español, alguien puede ayudarmeTema ¿Cuál.docx
Necesito un Essay en español, alguien puede ayudarmeTema ¿Cuál.docxNecesito un Essay en español, alguien puede ayudarmeTema ¿Cuál.docx
Necesito un Essay en español, alguien puede ayudarmeTema ¿Cuál.docx
 
Nature GeNetics  VOLUME 46 NUMBER 10 OCTOBER 2014 1 0 8 9.docx
Nature GeNetics  VOLUME 46  NUMBER 10  OCTOBER 2014 1 0 8 9.docxNature GeNetics  VOLUME 46  NUMBER 10  OCTOBER 2014 1 0 8 9.docx
Nature GeNetics  VOLUME 46 NUMBER 10 OCTOBER 2014 1 0 8 9.docx
 
Nature VS NurtureResearch writing 310Joi Tucker.docx
Nature VS NurtureResearch writing 310Joi Tucker.docxNature VS NurtureResearch writing 310Joi Tucker.docx
Nature VS NurtureResearch writing 310Joi Tucker.docx
 

Recently uploaded

Personalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaPersonalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
EADTU
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
AnaAcapella
 
Contoh Aksi Nyata Refleksi Diri ( NUR ).pdf
Contoh Aksi Nyata Refleksi Diri ( NUR ).pdfContoh Aksi Nyata Refleksi Diri ( NUR ).pdf
Contoh Aksi Nyata Refleksi Diri ( NUR ).pdf
cupulin
 

Recently uploaded (20)

male presentation...pdf.................
male presentation...pdf.................male presentation...pdf.................
male presentation...pdf.................
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio App
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
Rich Dad Poor Dad ( PDFDrive.com )--.pdf
Rich Dad Poor Dad ( PDFDrive.com )--.pdfRich Dad Poor Dad ( PDFDrive.com )--.pdf
Rich Dad Poor Dad ( PDFDrive.com )--.pdf
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...
 
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaPersonalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
Contoh Aksi Nyata Refleksi Diri ( NUR ).pdf
Contoh Aksi Nyata Refleksi Diri ( NUR ).pdfContoh Aksi Nyata Refleksi Diri ( NUR ).pdf
Contoh Aksi Nyata Refleksi Diri ( NUR ).pdf
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
 
OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...
 
How to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxHow to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptx
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
The Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDFThe Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDF
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
Observing-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxObserving-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptx
 

Mylib.pydef allInOne(n1, n2) return {addplus(n1, n2.docx

  • 1. Mylib.py def allInOne(n1, n2): return {"add":plus(n1, n2), "sub":subtract(n1, n2), "mult":multiply(n1, n2), "div": divide(n1, n2)} def IsInRange(lr, hr, n): return lr < n and n < hr #add 2 numbers def plus(n1,n2): add = n1 + n2 return add #subtract 2 numbers def subtract(n1, n2):
  • 2. sub = n1 - n2 return sub #multiply 2 numbers def multiply(n1, n2): mult = n1 * n2 return mult #division, n2 should not be zero def divide(n1, n2): try: div = n1/(n2 + 0.0) return div except ZeroDivisionError as e: print("The result of %s/%s = %s" % (n1, n2,"You cannot divide by Zero")) except Exception : print("Invalid input" , n1, n2)
  • 3. #expression calculator def scalc(val): try: #the epression is assumed to be comma separated ns = val.split(",") #split it into 3 parts #remove whitespaces in the components n1 = int(ns[0].strip()) n2 = int(ns[1].strip()) op = ns[2].strip() #check if operator is one of the supported if op == "*": return multiply(n1, n2) elif op == "/": return divide(n1, n2) elif op == "+": return plus(n1, n2)
  • 4. elif op == "-": return subtract(n1, n2) else: print("Unknown operator", op) #in case of invalid input catch the error except Exception : print("Invalid input:" , val) W6_first_last.py # Program name : # Student Name : # Course : ENTD220 # Instructor : # Date : 02/12/2020 # Description : Expression & Arithmetic Calculator # Copy Wrong : This is my work import Mylib def doScalc(): print("---------Expression calculator------------------") print("Enter the expression with format N1,N2,operator:") print("Supported operator * , /, -, +") print("E.g 5, 4, *)") val = input() res = Mylib.scalc(val)
  • 5. print('The result of "' + val + '" is', res) def showList(): print("1) Add two numbers") print("2) Multiply two numbers") print("3) Subtract two numbers") print("4) Divide two numbers") print("5) Scalc") print("6) All in one") print("7) Exit") def getUserInput(): low = int(input("Enter Lower range:")) high = int(input("Enter Higher range:")) n1 = int(input("Enter first number:")) n2 = int(input("Enter second number:")) return [low, high, n1 , n2] def doCalculation(op): user = getUserInput() low = user[0] high = user[1] n1 = user[2] n2 = user[3] if Mylib.IsInRange(low , high, n1) and Mylib.IsInRange(low , high, n2): if op == "+": res = Mylib.plus(n1, n2) elif op == "*": res = Mylib.multiply(n1, n2) elif op == "-": res = Mylib.subtract(n1, n2) elif op == "/": res = Mylib.divide(n1, n2) print("%d %s %d = %d" % (n1, op, n2, res))
  • 6. else: print("Error: input out of range") def doAllInOne(): user = getUserInput() low = user[0] high = user[1] n1 = user[2] n2 = user[3] if Mylib.IsInRange(low , high, n1) and Mylib.IsInRange(low , high, n2): mydict = Mylib.allInOne(n1, n2) print("%d + %d = %d" % (n1, n2, mydict["add"])) print("%d - %d = %d" % (n1, n2, mydict["sub"])) print("%d * %d = %d" % (n1, n2, mydict["mult"])) print("%d / %d = %d" % (n1, n2, mydict["div"])) def main(): while True: showList() action = int(input("What do you want to do?")) if action == 7: break; if action == 1: user = getUserInput doCalculation("+") elif action == 2: doCalculation("*") elif action == 3: doCalculation("-") elif action == 4: doCalculation("/") elif action == 5: doScalc() elif action == 6: doAllInOne()