Python Exercises
Local test
Project file tree
You should have retrieved the following file tree :
gitlabciintroduction/
└── python/
├── raw/
│ └── ... # files used later
├── sphere
└── gitlabciintroduction/
├── __init__.py
├── sphere.py
└── test/
├── __init__.py
└── sphere_test.py
Project presentation
This project aims to compute a sphere volume. As simple as it can be, we want it packaged, and properly tested. Your goal is to create a package, named gitlabciintroduction, with a sphere submodule and a command line interface (or cli) script to run it.
Try the sphere script with a radius as argument:
$ ./sphere 3.
...
AttributeError: 'Sphere' object has no attribute 'volume'
Exercise
- Write the Sphere.volume method. For that, use math module and remember volume formula you learned in school: 4 * PI * R^3 / 3
- Commit your code with a meaningfull message and push.
Home | Python Home | << Python Previous - Branch creation | >> Python Next - Packaging