Introduction to Programming 2024/2025 (CC1024) - DCC/FCUP

Practical Class #07 - Dictionaries and Sets (11/11 to 15/11)


Exercises for submission

In what concerns the "exercises during classes" component of the evaluation, the exercises that you can submit for this class are:

Deadline for submission: November 30th (submit to IP's Mooshak)

You are encouraged to talk to the professors and your colleagues if you encounter difficulties. However, any more direct help that you receive should be acknowledged in the comments of the code you submit.
After the deadline the problems will still be available on Mooshak, but the submissions will not count towards your grade.
Each practical class is worth 10% of your final component for exercices during class. Since there will be 11 classes with submissions, you can achieve maximum grade even without doing all classes.
For a problem to count you must pass all tests (that is, to have an accepted). Even if you solve all problems, the maximum on one class is 100%.
To obtain 100% it will always be enough to solve the main exercises.


With the exercises in this class you will develop the following skills:

  1. Explore function definition and function calling
  2. Understand the concept of dictionaries and how you can use them in Python
  3. Know how to traverse, insert, remove and modify elements in dictionaries
  4. Understand the concept of sets and how you can use them in Python
  5. Know how to traverse, insert and remove elements in sets
  6. Gain experience with some algorithmic patterns

If you feel stuck, go back and revise all the lectures, but in particular the following ones: T08: Tuples and Lists | T09: More (on) Lists | T10: Advanced Lists


1) Working with dictionaries

The first set of problems will give you the basics about dictionaries.


Read the statements, code and try to submit Accepted solutions to all of the following problems. Don't forget to test first on your computer!

  1. [IP063] Price Increase (changing a value in the dictionary)
  2. [IP064] Dish Renaming (removing and adding new keys)
  3. [IP065] Reversed Menu (traversing and creating a dictionary)
  4. [IP066] A New Translation (traversing and creating a dictionary)
  5. [IP067] High Price (dictionaries and lists)


2) Working with sets

The second set of problems will give you the basics about dictionaries.


Read the statements, code and try to submit Accepted solutions to all of the following problems. Don't forget to test first on your computer!

  1. [IP068] Price Diversity (creating a set from a dictionary)
  2. [IP069] Items Removal (removing elements from a set, careful with traversing while changing)
  3. [IP070] Coin Change (creating and and updating a set)


3) Extra exercises for consolidating your knowledge [extra]

Loved the main exercises and want extra problems? Here are more exercises to sharpen your skills.


Read the statements, code and try to submit Accepted solutions to all of the following problems. Don't forget to test first on your computer!

  1. [IP071] Restaurant Inventory (frequency count)
  2. [IP072] Super Reversed Menu (inverting a dictionary)
  3. [IP073] Allowed Digits (digits and set operations)

4) Challenge exercise [challenge]

You've done it! You've tackled every taskfrom the Bob's Burgers series 🍔✨. You've navigated the menu, mastered the recipes, and have shown that you have the creativity and skills of the Belcher family! Now one challenge remains...


Read the statement, code and try to submit an Accepted solution to the following problem. Don't forget to test first on your computer!

  1. [IP074] Saving Coins

Happy coding! 😊