Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

should be done in Python. the second picture is what the output should look like SUBMISSION INSTRUCTIONS Submit 2 python files using the naming convention

should be done in Python. the second picture is what the output should look like image text in transcribed
image text in transcribed
SUBMISSION INSTRUCTIONS Submit 2 python files using the naming convention below (replace JaneDoe with your first and last name respectively): - formulas.py - JaneDoe3 1.py QUESTION 1. Create a module named formulas that contains the functions below: a. def add(values): This function should return the sum of all the numbers in the list values. b. def subenct(values): This function should return the difference of all the numbers in the hist values. c. def multiply(values): This function should return the product of all the numbers in the list values. d. def divide(values). This function should return the result of dividing all the numbers in the list values. If the first number is 0 the result should be 0 but if any of the other numbers are 0 . use the sys exit method to stop the program and display the exit message Cannot divide by 0 . 2. In JaneDoe3 1, 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 1 , with the help of sys exit, exit the program with the mesage Need to provide the operator name. ii. If the length is less thin or equal to 3 , with the help of sys exit, exit the program with the message Need to provide at least two values. ii. If the length is greater than 3 , retrieve the openater's name and all the values. Assume all the values that come after the operntor's 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 fomulas py to perform the operations. Display your answer to 2 decimal places. Refer to the sample output below on how yout program output should look like. Please note: - Your results should be displayed to 2 decimal plices. - Look over the final statement in the smmple output to see how to deal with an imvalid operator name - Module names are traditionally lower ease so use the name provided when giving your module a name. SAMPLE OUTPUT Need to provide the operator name PS C: \Users\0wora\Desktop\Python> python JaneDoe3_1.py add Need to provide at least two values PS C: \Users\Owora\Desktop\Pythons python JaneDoe3_1.py add Answer =3.00 PS C: \Users\0wora\Desktop\Pythons python JaneDoe3_1.py subtract Answer =4.00 PS C: \Users\Owora\Desktop\Pythons python JaneDoe3_1.py multiply Answer =0.00 Answer =0,5 Answer =0.00 Cannot divide by PS C: \Users\Owora\Desktop\Python> python JaneDoe3_1.py divide Answer =1.67 PS C: \Users\0wora\Desktop\Python> python JaneDoe3_1.py test Valid operator names (add, subtract, multiply, divide)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems A Practical Approach To Design Implementation And Management

Authors: THOMAS CONNOLLY

6th Edition

9353438918, 978-9353438913

More Books

Students also viewed these Databases questions