lab03a : Conditionals, Nested Control Structures, and Loops
num | ready? | description | assigned | due |
---|---|---|---|---|
lab03a | true | Conditionals, Nested Control Structures, and Loops | Thu 01/23 12:00AM | Sun 02/23 12:00AM |
This lab, originally lab03 from Summer 2019 (by Prof. Richert Wang), offers more opportunity to practice the skills from lab03.
There is some overlap with the other labs in the course, but also some new material as well.
In this lab, you’ll get more practice with:
- Writing functions
- Testing your functions with pytest
- Using conditionals and nested control statements
- Using loops to iterate through containers
Instructions
In this lab, you will need to create two files:
lab03a.py
- file containing function definitionslab03a_tests.py
- file containing test cases- Please comment you and your partner’s name (if applicable) at the top of each file.
Starter code is provided for you and are located at (you may need to refresh the page if the links do not load immediately):
lab03.py
lab03_tests.py
You will complete the portions in the starter code by doing the following:
- Create a directory called ~/cs8/lab03a (using the
mkdir
command) andcd
into that directory. - Use
idle3
(you might tryidle3 &
if you want to be able to type commands on your terminal window after IDLE opens). - Use “New File” to create empty files called
lab03a.py
andlab03a_tests.py
in that~/cs8/lab03a
directory. - ONE AT A TIME, copy the function definitions from the starter code, and the tests that go along with those functions, and get the tests to pass.
- By one a a time, what I mean is, at your first step, copy ONLY the first function definition from the starter code
lab03a.py
and copy only the import statements and test cases fromlab03a_tests.py
that go with that function definition. - Then, before you move on to the next function definition and its tests, get all of the tests from the one you just copied to pass.
- Then, and only then, copy the next function definition and its tests into your files.
- Repeat this until you have ALL of the function definitions and their tests, and all of them pass.
- By one a a time, what I mean is, at your first step, copy ONLY the first function definition from the starter code
You are encouraged to try submitting to Gradescope periodically for several reasons:
- You can get partial credit if some of your tests pass for some of your functions.
- You will have a backup of your file in case you accidentally delete yours, or in case your laptop dies.
- You can move code between your laptop and CSIL by downloading your submitted code from Gradescope
Upload lab03a.py
and lab03a_tests.py
to Gradescope.
Once you’re done with writing your functions, navigate to the Lab
assignment “Lab03” on Gradescope and upload your lab03a.py
and
lab03a_tests.py
files.