Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Question
100%

This task involves creating two scripts, one for each part!

TASK 1

1. Create a Python module named module.py.

2. This module must define four functions:

     a. add(a, b)

     b. subtract(a, b)

     c. multiply(a, b)

     d. divide(a, b)

     e. Divide must check for division by zero and return an error message if it encounters it.

3. Each function should take two arguments and perform the corresponding mathematical operation. Return the result, don’t print it in the function.

4. Include a main() function that tests these functions with some example inputs. Ensure that you print the results of the function calls here in the main function and provide the appropriate labels.

5. The main() function must only run automatically if the module is being run directly, not when imported.

TASK 2

6. Create another Python script named in the same directory as module.py.

7. This new script must import the module you created in Part 1 of this task.

     a. Tip: You import the module with import <name of file to import wthout the .py extension)

8. In this script, call each function from the module with different inputs than the ones you used when testing it in the main() method of the module. You don’t need a main function in this script file.

9. Ensure that the main() function from the imported module does not run when you execute this script. a. You shouldn’t need to do anything here if you completed step 5, just verify that this is working correctly.

Here is a screenshot of the expected behavior, testing all scenarios described above. Replicate
this functionality in your solutions, including the formatting and outputs of all messages.

 

 

 

eric@iftlinux:~/lab_h$ ./lab_h_task_01_module_sdevil.py
Testing for operands 6 and 3
Add: 9
Subtract: 3
Multiply: 18
Divide: 2.0
eric@iftlinux:~/lab_h$ ./lab_h_task_01_script_sdevil.py
Testing for operands 10 and 5
Add: 15
Subtract: 5
Multiply: 50
Divide: 2.0
expand button
Transcribed Image Text:eric@iftlinux:~/lab_h$ ./lab_h_task_01_module_sdevil.py Testing for operands 6 and 3 Add: 9 Subtract: 3 Multiply: 18 Divide: 2.0 eric@iftlinux:~/lab_h$ ./lab_h_task_01_script_sdevil.py Testing for operands 10 and 5 Add: 15 Subtract: 5 Multiply: 50 Divide: 2.0
Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education