Login and get codingWelcome to this type hinting learning path. In the Bites of this learning path you will annotate a lot of different Python objects with type hints. The first two Bites are meant to familiarize yourself with type hints and to use both the basic data types as well as some more specialized types from the
typing
module.However, beginning with the third Bite, you will start working with code for a simple application that uses vectors and matrices. With each following Bite you will dive deeper into the code and use more and more complex type hints to annotate the code further. To this end, it is often important that you first understand what the code does, so that you will be able to choose the right type hint for the task at hand.
If you are new to typing / type annotations, maybe you want to read the Pybites article series about typing first or in an addition to this learning path. Of course, you can always ask the official documentation for help, though. There is the documentation of the typing module (be aware of the correct Python version that you are using!) as well as a lot of Python Enhancement Proposals (PEP), also linked in the module's documentation. Given that the official documentation, and PEPs in particular, are often not the easiest reading material, I found the mypy documentation a very good starting place.
Your Task
In this Bite, you have to add type hints to all functions, both globally and within the
BankAccount
class. Make sure you annotate both the function's parameters as well as the return type of each function.For this Bite, we keep it simple, so only basic data types are needed and no
typing
module.Note: please be patient if the platform does not instantly show the test results, the last final test (test_mypy_report) takes at least 10 seconds to run. However, in return we are not limited to checking concrete types, allowing multiple options in your code submissions. Thanks.
43 out of 45 users completed this Bite.
Will you be the 44th person to crack this Bite?
Resolution time: ~28 min. (avg. submissions of 5-240 min.)
Our community rates this Bite 3.0 on a 1-10 difficulty scale.
» You can do it! 😌