Before we start writing the exercises, I want to discuss how to write programs that are documented and tested using the following principles. Specifically, we’re going to:
|
|
It’s pretty common to write "Hello, World!" as your first program in any language, so let’s start there. We’re going to work towards making a version that will greet a name that is passed as an argument. It will also print a helpful message when we ask for it, and we’re going to use tests to make sure it does everything correctly. In the 01_hello
directory, you’ll see there several versions of a "hello" program we’ll write. There is also a program called test.py
that we’re going use to test the program.
Start off by creating a text file called hello.py
in that directory. If you are working in VSCode or PyCharm, you can use "File → Open" to open the 01_hello
directory as a project. Both tools have something like a "File → New" menu option that will allow you to create a new file in that directory. It’s very important to create the hello.py
file inside the 01_hello
directory so that the test.py
program can find it!
Once you’ve started a new file, add this line: