Welcome to the first session of Coding Club!
In this session, we will be looking at how to clean up your Python code into scripts and modules. This will make your work easy to use and distribute, both for yourself and others!
The slides are available here.
Fire up a GitHub Codespace from this repository to test out the examples in
realtime. You can hit the + sign in the top right hand corner of GitHub, and
select "New Codespace", then search for this repository, under
jacanchaplais/python-modules-and-scripts
. This will give you a virtual
machine in the cloud which you can use to follow along with. Code examples are
stored under src/
.
Starting from the src/6_installable/wavey/
directory:
- Add a new wave function to
__init__.py
(eg.tan_wave()
)- Be sure to document the function
- Edit
generate()
function in__main__.py
options:- Add an option to select which wave form to use (if you did ex 1)
- Hint: the relevant section of
click
's docs
- Hint: the relevant section of
- Edit
--noise
option so that it takes a numerical value, to allow the scale of the noise to be set in the CLI - Add an option to select the interval of angles data is created for
- Add an option to select which wave form to use (if you did ex 1)
- Add option to
plot()
function to change the line style of the figure