In what concerns the "exercises during classes" component of the evaluation, the exercises that you can submit for this class are:
Deadline for submission: January 3rd (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 have received from other colleagues or LLMs 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:
Knowing how to catch, handle, and raise exceptions in your code helps you ensure your program behaves as expected, even when encountering errors. This week, you will explore several runtime errors that arise most frequently while we're coding, and learn useful strategies to catch and bypass them! Make sure to take a look at: T21: Exceptions to follow along the exercises!
This week's theme for the exercises is The Matrix.

1) Neo's Error Awakening [main]
![]()
For this exercise you will be solving the problem [IP102] Neo's Error Awakening.
Read the statement, code and try to submit an Accepted solution. Don't forget to test first on your computer!
In this simple exercise, you'll have to specifically catch two common types of errors, ZeroDivisionError and TypeError.
Take a look at T21: Exceptions and try to define the proper blocks to catch these exceptions.
2) A Glitch in the Matrix [main]
![]()
For this exercise you will be solving the problem [IP103] A Glitch in the Matrix.
Read the statement, code and try to submit an Accepted solution. Don't forget to test first on your computer!
Imagine that you don't really know the exception that might be raised in your code. How can you capture any exception?
Can you revisit T21: Exceptions and find out what except Exception as error: does?
How about type(error).__name__?
3) The Wisdom of the Oracle [main]
![]()
For this exercise you will be solving the problem [IP104] The Wisdom of the Oracle.
Read the statement, code and try to submit an Accepted solution. Don't forget to test first on your computer!
Now you'll have a function that receives a function as input! What happens when you try to call a function that raises an error?
Can you wrap this function call in a try block? And if it raises an error... incrementing a counter? 😉
4) Trinity's Escape [main]
![]()
For this exercise you will be solving the problem [IP105] Trinity's Escape.
Read the statement, code and try to submit an Accepted solution. Don't forget to test first on your computer!
Take a look at T21: Exceptions to find how to raise an Exception with a customized text message.
Can you find the positions of Trinity, the agents and the booths? Can you compute the distance between a pair of positions? Can you use that to solve the problem? 😎
5) Cypher's Betrayal [extra]
![]()
For this exercise you will be solving the problem [IP106] Cypher's Betrayal.
Read the statement, code and try to submit an Accepted solution. Don't forget to test first on your computer!
You do remember that input() reads one line of the standard input, right?
Evaluate each string line using eval(line) and catch any exception.
You can use a map to keep the frequencies (using the type name as the key and the frequency as the value).
How can you sorted based on frequency? You already did similar problems, right? 😉
You're finally facing the wrath of Agent Smith! Good luck!
![]()
For this exercise you will be solving the problem [IP107] Hello, Mr. Anderson
Read the statement, code and try to submit an Accepted solution to the following problem. Don't forget to test first on your computer!
Happy coding! 😊