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 4th (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:
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 erros that arise most frequently while we're coding, and learn useful strategies to catch and bypass them! Make sure to take a look at: T20: 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 [IP097] 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 T20: 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 [IP098] 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 raise in your code. How can you capture any exception?
Can you revisit T20: 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 [IP099] 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... when update the counter(?) 😉
4) Trinity's Escape [main]
For this exercise you will be solving the problem [IP100] Trinity's Escape.
Read the statement, code and try to submit an Accepted solution. Don't forget to test first on your computer!
Wow, we reache 100 exercises, can you believe it? Congrats, you're becoming a fantastic programmer by now! Maybe one day you'll be visited by Morpheus as well 😁
Now, on to help Trinity escape! Take a look at T19: Modules. We've explored a module named random
that let's us generate pseudo-random numbers! Can we use that to delete random booths?
We've also seen what happens when a key does not exist in a dictionary... can you "see" it now?
5) Cypher's Betrayal [extra]
For this exercise you will be solving the problem [IP101] Cypher's Betrayal.
Read the statement, code and try to submit an Accepted solution. Don't forget to test first on your computer!
Each result is the sum of two consecutive elements from a list. However, if an element cannot be summed to its next element in i+1
, then we have to skip it.
Be careful, the list may contain non-integers, like None
... and it may also contain strings. Strings can be "summed", i.e., "A" + "B" = "AB"
, but we don't want this to happen...
You're finally facing the wrath of Agent Smith! Good luck!
For this exercise you will be solving the problem [IP102] 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! 😊