Exercise 00 – Only Real 90s kids make the cut!
- In the
comp110/exercises
directory create a new folder named ex08_dicts
- Create a file named
students_over_21.py
in your comp110/exercises/ex08_dicts
folder.
- Write a function with the following signature:
- Name:
students_over_21
- Argument(s): A
Dict[str, int]
containing students’ names and their corresponding birth year
- Returns: A
List[str]
of student’s names.
- The function should return a list of student’s names that were born in or before 1999.
Example program run:
students_over_21({"Kris": 2000, "Kaki": 1998, "Marlee": 1994}) -> ["Kaki", "Marlee"]
Exercise 01 – Test Average!
- Create a file named
average_score.py
in your comp110/exercises/ex08_dicts
folder.
- Write a function with the following signature:
- Name:
average_score
- Argument(s): A
Dict[str, float]
containing students’ names and their test score.
- Returns: A
float
.
- The function should return the average test score amongst all students.
Example program run:
average_score({"Marc": 100.0, "Ezri": 100.0, "Kris": 23.7}) -> 74.56666666666666
Exercise 02 – Colors!
- Create a file named
favorite_color.py
in your comp110/exercises/ex08_dicts
folder.
- Write a function with the following signature:
- Name:
favorite_color
- Argument(s): A
Dict[str, str]
containing students’ names and their favorite color.
- Returns: A
str
.
- The function should return the color that appears most frequently.
- If there is a tie for most popular color, return the color that appeared in the dictionary first.
Example program run:
favorite_color({"Marc": "yellow", "Ezri": "blue", "Kris": "blue"}) -> "blue"
Testing
In your ex08_dicts
directory, set up a file ex08_test.py
where you should add tests to assert the correctness of your implementation. Before coming to office hours, you must have some failing test cases here.
- You should have a module docstring with a complete first sentence describing your progam at the start of each exercise.
- In each of your files, initialize a global variable named author set equal to your PID as a string
Submission
Go ahead and delete any submission zips lingering around in your workspace from the previous exercise.
When you are ready to submit for grading, close out any open Python Debug Console terminals using the Trash Can and then open up a clean, new terminal.
python -m tools.submission comp110/exercises/ex08_dicts
This should produce a submission timestamped with the current date/time for uploading on Gradescope.
Make a Backup Commit
- Open the Source Control panel (Command Palette: “Show SCM” or click the icon with three circles and lines on the activity panel).
- Notice the files listed under Changes. These are files you’ve made modifications to since your last backup.
- Move your mouse’s cursor over the word Changes and notice the + symbol that appears. Click that plus symbol to add all changes to the next backup. You will now see the files listed under “Staged Changes”.
- If you do not want to backup all changed files, you can select them individually. For this course you’re encouraged to back everything up.
- In the Message box, give a brief description of what you’ve changed and are backing up. This will help you find a specific backup (called a “commit”) if needed. In this case a message such as, “Finished Exercise 0!!” will suffice.
- Press the Check icon to make a Commit (a version) of your work.
- Finally, press the Ellipses icon (…) and select “Push” to send this backed up version to your workspace repository space on GitHub.