Sale!

CPSC223 Lab 4

$30.00 $18.00

Category: You will Instantly receive a download link for .zip solution file upon Payment || To Order Original Work Click Custom Order?

Description

5/5 - (1 vote)

Laboratory Objectives

1. Write a Python program using:
i. modules
ii. packages
iii. functions using keyword arguments

2. Run and test a Python program.

Program Instructions

1. Write a Python package with sub-packages, modules, and functions using
keyword arguments. Use the following directory outline and module names (your
first starting point should be a directory called mathematics within an empty
directory
mathematics/
__init__.py
whoami.py
numbers/
__init__.py
whoami.py
series.py
simple.py
geometry/
__init__.py
whoami.py
rectangle.py
circle.py
cube.py

2. Create a mathematics package.
i. Initialize the __all__ variable to the whoami module.
ii. Create a whoami module.
a. Create a function named getname which returns the __name__ variable.
iii. Create a numbers sub-package:

a. Initialize the __all__ variable so that the whoami and series modules (and not
the simple module) can be imported when
‘from mathematics.numbers import *’ is encountered.
b. Create a whoami module.

a. Create a function named getname which returns
the __name__ variable.
c. Create a series module:

a. Create a function named sum which receives a keyword
parameter list and returns the sum of all the values in the list.
b. Create a function named average which receives a keyword
parameter list and returns the average of all the values in the list.
d. Create a simple module:

a. Create a function named addition which receives the keyword
parameters left and right and returns left plus right.
b. Create a function named subtraction which receives the keyword
parameters left and right and returns left minus right.

c. Create a function named multiplication which receives the keyword
parameters left and right and returns left multiplied by right.
d. Create a function named division which receives the keyword
parameters left and right and returns left divided by right.
iv. Create a geometry sub-package.

a. Initialize the __all__ variable so that the whoami, circle, and cube modules (and
not the rectangle module) can be imported when ‘from mathematics.geometry
import *’ is encountered.
b. Create a whoami module:
a. Create a function named getname which returns
the __name__ variable.

c. Create a rectangle module:
a. Create a function named perimeter which receives a keyword
parameters length and width and returns (2l + 2w).
b. Create a function named area which receives a keyword
parameters length and width and returns (l * w).

d. Create a circle module:
a. Create a function named circumference which receives the keyword
parameter radius and returns (2 * pi * r).
b. Create a function named area which receives the keyword
parameter radius and returns (pi * r * r).

e. Create a cube module.
a. Create a function named surface_area which receives the keyword
parameter side and returns (s * s * 6).
b. Create a function named volume which receives the keyword
parameter side and returns (s * s * s).

3. Create your own main.py file to import and test all the modules and functions until you are
satisfied your program output meets the above requirements. I will not grade this file – it is for
your use to test the package.

Submission
Zip the directory structure (and all its files) shown in step 1 of the instruction above and upload the zip
file to Canvas