Skip to content
Foxipa
Code Completion 4 Challenges

Complete the Python packages and imports code

Practice creating package imports, accessing submodules, and using a relative import inside a package.

Beginner ~7 min read

Challenge 1

Import the pricing submodule from the shop package so that shop.pricing can be used below.

python Your answer

print(shop.pricing.total_with_tax(100))

Press Ctrl⌘Enter to check your answer

Challenge 2

Import the pricing submodule from shop so that pricing can be used directly below.

python Your answer

print(pricing.total_with_tax(100))

Press Ctrl⌘Enter to check your answer

Challenge 3

Inside shop/reports.py, import the sibling pricing module using a relative import.

python Your answer

print(pricing.total_with_tax(100))

Press Ctrl⌘Enter to check your answer

Challenge 4

In shop/__init__.py, define the package name as "Shop" so that shop.package_name is available after importing shop.

python Your answer

Press Ctrl⌘Enter to check your answer