- Write Python code using any editor.
- Execute the program from the command line.
- Unit test the program.
- Upload on Canvas for submission
-
Setting Up Python Environment
- Verify Python Installation:
- Open your terminal (Command Prompt for Windows, Terminal for macOS/Linux).
- Type
python --versionand press Enter. - You should see the installed Python version displayed.
-
Configuring Visual Studio Code (VS Code)
- Install Python Extension:
- Open VS Code.
- Go to the Extensions view by clicking on the Extensions icon in the Activity Bar on the side of the window or by pressing Ctrl+Shift+X.
- Search for
Pythonin the Extensions Marketplace. - Click “Install” on the Python extension by Microsoft.
-
Running Python in VS Code
- Create a New Python File:
- In VS Code, open a folder where you want to save your Python projects.
- Click on File > New File or press Ctrl+N to create a new file.
- Save the file with a .py extension (e.g.,
hello.py).
-
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
mathematicswithin yourlab05-usernamedirectory):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 -
Create a
mathematicspackage.- Initialize the
__all__variable to thewhoamimodule. - Create a
whoamimodule.- Create a function named
getnamewhich returns the__name__variable.
- Create a function named
- Create a
numberssub-package.- Initialize the
__all__variable to thewhoamiandseriesmodules. - Create a
whoamimodule.- Create a function named
getnamewhich returns the__name__variable.
- Create a function named
- Create a
seriesmodule.- Create a function named
sumwhich receives a keyword parameterlistand returns the sum of all the values in the list. - Create a function named
averagewhich receives a keyword parameterlistand returns the average of all the values in the list.
- Create a function named
- Create a
simplemodule.- Create a function named
additionwhich receives the keyword parametersleftandrightand returns left plus right. - Create a function named
subtractionwhich receives the keyword parametersleftandrightand returns left minus right. - Create a function named
multiplicationwhich receives the keyword parametersleftandrightand returns left multiplied by right. - Create a function named
divisionwhich receives the keyword parametersleftandrightand returns left divided by right.
- Create a function named
- Initialize the
- Create a
geometrysub-package.- Initialize the
__all__variable to thewhoami,circle, andcubemodules. - Create a
whoamimodule.- Create a function named
getnamewhich returns the__name__variable.
- Create a function named
- Create a
rectanglemodule.- Create a function named
perimeterwhich receives a keyword parameterslengthandwidthand returns (2l + 2h). - Create a function named
areawhich receives a keyword parameterslengthandwidthand returns (l * h).
- Create a function named
- Create a
circlemodule.- Create a function named
circumferencewhich receives the keyword parameterradiusand returns (2 * pi * r). - Create a function named
areawhich receives the keyword parameterradiusand returns (pi * r * r).
- Create a function named
- Create a
cubemodule.- Create a function named
surface_areawhich receives the keyword parametersideand returns (s * s * 6). - Create a function named
volumewhich receives the keyword parametersideand returns (s * s * s).
- Create a function named
- Initialize the
- Initialize the
-
Create your own main.py file to test all the modules and functions and run the program using the command below and repeat the steps above 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.
python3 -m main -
Run the unit testing program to ensure that your program runs as expected.
For Linux and Mac users
./test.sh or source ./test.shFor windows users
./win_test.batThe unit testing will output the results of a series of tests using specific input and expected output. Any error will provide information on where the expected output is different from the actual output. You will need to edit your source code to fix the error and run
./test.shor./win_test.batrepeatedly until it passes all the test.
Submit a zip file containing all the code files on canvas
Naming Convention: _.zip
'''
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
'''
- All points add up to a total of 100 points possible as detailed below. Partial credit will be given where applicable.
| Points | Description |
|---|---|
| 50 | Environment setup and Lab Submission |
| 1 | mathematics/init.py file submitted and meets the program requirements |
| 1 | mathematics/whoami.py file submitted and meets the program requirements |
| 1 | mathematics/numbers/init.py file submitted and meets the program requirements |
| 2 | mathematics/numbers/whoami.py file submitted and meets the program requirements |
| 2 | mathematics/numbers/series.py file submitted and meets the program requirements |
| 2 | mathematics/numbers/simple.py file submitted and meets the program requirements |
| 1 | mathematics/geometry/init.py file submitted and meets the program requirements |
| 2 | mathematics/geometry/whoami.py file submitted and meets the program requirements |
| 2 | mathematics/geometry/rectangle.py file submitted and meets the program requirements |
| 2 | mathematics/geometry/circle.py file submitted and meets the program requirements |
| 2 | mathematics/geometry/cube.py file submitted and meets the program requirements |
| 2 | unit test passes Test01_mathematics_whoami_getname |
| 2 | unit test passes Test02_mathematics_numbers_whoami_getname |
| 2 | unit test passes Test03_mathematics_numbers_series_sum |
| 2 | unit test passes Test04_mathematics_numbers_series_average |
| 2 | unit test passes Test05_mathematics_numbers_simple_addition |
| 2 | unit test passes Test06_mathematics_numbers_simple_subtraction |
| 2 | unit test passes Test07_mathematics_numbers_simple_multiplication |
| 2 | unit test passes Test08_mathematics_numbers_simple_division |
| 2 | unit test passes Test09_mathematics_geometry_whoami_getname |
| 2 | unit test passes Test10_mathematics_geometry_rectangle_perimeter |
| 2 | unit test passes Test11_mathematics_geometry_rectangle_area |
| 2 | unit test passes Test12_mathematics_geometry_cube_surfacearea |
| 2 | unit test passes Test13_mathematics_geometry_cube_volume |
| 2 | unit test passes Test14_mathematics_init |
| 2 | unit test passes Test15_mathematics_numbers_init |
| 2 | unit test passes Test16_mathematics_geometry_init |