lab04 : More Loops - Accumulator Pattern, Updating Lists, and Filtering Lists
num | ready? | description | assigned | due |
---|---|---|---|---|
lab04 | true | More Loops - Accumulator Pattern, Updating Lists, and Filtering Lists | Wed 02/14 08:00AM | Sun 02/18 11:59PM |
In this lab, you’ll get more practice with:
- Writing functions
- Testing your functions with pytest
- Using more nested control statements and checking types
- Using loops to iterate through containers
- Using the accumulator pattern and filtering through lists
This lab may be done solo, or in pairs.
Before you begin working on the lab, please decide if you will work solo or with a partner.
A reminder about working with a pair programming partner:
- Your partner must be enrolled in the same lab section as you.
- You and your partner must agree to work together outside of lab section in case you do not finish the lab during your lab time. You must agree to reserve at least two hours outside of lab section to work together if needed (preferrably during an open lab hour where you can work in Phelps 3525 and ask a mentor for help). You are responsible for exchanging contact information in case you need to reach your partner.
- If you choose to work with a partner, then you must choose a partner you have not worked with before.
- You MUST add your partner on Gradescope when submitting your work EACH TIME you submit a file(s). After uploading your file(s) on Gradescope, there is a “Group Members” link at the bottom (or “Add Group Member” under “Groups”) where you can select the partner you are working with. Whoever uploaded the submission must make sure your partner is part of your Group. Click on “Group Members” -> “Add Member” and select your partner from the list.
Once you and your partner are in agreement, choose an initial driver and navigator, and have the driver log into their account.
Instructions
In this lab, you will need to create two files:
lab04.py
- file containing function definitionslab04_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):
- https://ucsb-cs8-w18-wang.github.io/lab/lab04/lab04.py
- https://ucsb-cs8-w18-wang.github.io/lab/lab04/lab04_tests.py
You will complete the portions in the starter code by doing the following:
- Create a directory called ~/cs8/lab04 (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
lab04.py
andlab04_tests.py
in that~/cs8/lab04
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
lab04.py
and copy only the import statements and test cases fromlab04_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 lab04.py
and lab04_tests.py
to Gradescope.
Once you’re done with writing your functions, navigate to the Lab assignment “Lab04” on Gradescope and upload your lab04.py
and lab04_tests.py
files. Remember to add your partner to Groups Members for this submission on Gradescope if applicable. At this point, if you worked in a pair, it is a good idea for both partners to log into Gradescope and see if you can see the uploaded files for Lab04.