Challenge: Create a Package
00:00 It’s time for a challenge. The challenge is a bit more involved than the review exercises because you should build an entire package yourself. And here are the details:
00:11
In a project folder called package_exercises/, create a package called helpers with three modules: __init__.py, string.py, and calc.py. In the string.py module, add a function called shout() that takes a single string parameter and returns a new string with all the letters in uppercase.
00:36
In the calc.py module, add a function called area that takes two parameters called length and width and returns their product, length multiplied by width.
00:49
In the package_exercises/ folder, create a module called main.py that imports the string and calc modules.
00:57
Use string.shout() and calc.area() to print the following output: THE AREA OF A 5-BY-8 RECTANGLE IS 40. I’m saying this a bit louder because I mean, it’s uppercase.
01:09
It’s the shout() function after all, right?
01:13 So that’s the challenge. Again, you can stop the video course here and work on the challenge yourself. This is a bit more involved, so take your time. And once you’re ready, come back to the video course to the next lesson, where you will see how I tackle the challenge, and then we can compare our solutions.
Become a Member to join the conversation.
