Question: Create a Module: Create a Python file named math _ operations.py that includes the following: A function add ( a , b ) that returns

Create a Module: Create a Python file named
math_operations.py that includes the following:
A function add(a, b) that returns the sum
of a and b.
A function subtract(a, b) that returns the
difference between a and b.
A constant PI =3.14159.
Write a Script to Use the Module:
In a new file (e.g., main.py), import the math_operations
module and use the functions and constant:
Import the entire module and call the add and subtract functions with
different values.
Print the result of add(5,3) and subtract(10,4).
Print the value of PI from the math_operations
module.
Advanced Imports:
Modify main.py to import only the add function from math_operations
using from math_operations import add.
Call the add function and print the result of add(7,2).Use an alias (e.g.,
import math_operations as mo) to access the PI constant.
Create a new file geometry.py inside the same folder, and add a function circle_area(radius)
that calculates and returns the area of a circle using the formula: area = PI *
radius^2.In your main.py, import circle_area from geometry.py and calculate
the area for a circle with a radius of 5.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!