Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1 . Create a module named formulas that contains the functions below: a . def add ( values ) : This function should return the
Create a module named formulas that contains the functions below:
a def addvalues: This function should return the sum of all the negative numbers in the list values. If none is present in the list, return the sum as
b def subtractvalues: This function should return the difference of all the positive numbers in the list values. If none is present in the list, return the difference as
c def multiplyvalues: This function should return the product of all the nonzero numbers in the list values. If none is present in the list, return the product as
d def dividevalues: This function should return the result of dividing all the numbers in the list values. If the first number is the result should be except in situations where there are other numbers in the list that are ; in that case, use the sysexit method to stop the program and display the exit message Cannot divide by All this logic should be placed in the divide function.
Please note: The functions in this module should only return numeric values back to the main program. Dont return formatted string output.
In JaneDoe write code that will:
a Check the length of the arguments being sent via the terminal.
i If the length is less than or equal to with the help of sysexit, exit the program with the message Need to provide operator.
ii If the length is less than or equal to with the help of sysexit, exit the program with the message Need to provide at least two values.
iii. If the length is greater than retrieve the operators name and all the values. Assume all the values that come after the operators name will be numbers. When you retrieve them from the terminal, save them into a list as floats.
b Depending on the name of the operator provided, call the functions in formulas.py to perform the operations.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started