Search the courses, subjects, tracks, games and features, or jump straight to a page.
2 cards from this section. Quick, good the night before a test.
What file is essential for creating a package in Python?
Think about the file needed to recognize a directory as a package.
Can init.py be empty?
Consider situations where a file might not contain any code.
What is the purpose of init.py?
Think about what signals Python about the directory.
True or False: init.py must always contain code.
Consider whether there’s a scenario where no code is needed.
You need to create a package with multiple modules: calculator.py, geometry.py, and statistics.py. Write an appropriate init.py file that exposes only certain functions.
Determine which functions should be most useful to users.
Design init.py for a package that needs to run some initialization code upon import. What should that look like?
Consider what kind of initialization is helpful when a package is first imported.
4 more questions in this section. Enroll free to practise them all.
Enroll free