Last Updated: January 3, 2026
30 quizzes
Complete the import so you can calculate the square root of 49 using the math module
print(.sqrt(49))Click an option to fill the blank:
Complete the code so it imports the greet function directly from the helpers module inside tools package
from tools.helpers import Click an option to fill the blank:
Complete the expression so it shows the absolute filesystem path of the current file using the os.path module
print(os.path.(__file__))Click an option to fill the blank:
What is a Python module?
Which import statement avoids bringing all names from a module into the current namespace?
Which statement correctly imports the random module with an alias?
You have a directory analytics with several .py files and an empty __init__.py. What is analytics considered?
Which __init__.py feature controls what is imported with from package import *?
Which module from the standard library is best suited for working with JSON data?
Which pip command upgrades an already installed package named requests?
Why are virtual environments commonly used in Python projects?
You want to use only the date class from datetime. Which import is most appropriate?
Where does Python look first when you import a module named mytool?
Which statement about creating a module is accurate?
Which standard library module helps build file paths in a platform-independent way?
Order the steps to create and use a simple custom module named math_tools in the same directory.
Drag and drop to reorder, or use the arrows.
Order the steps to create a reusable package named utilities with a string_tools module and use it.
Drag and drop to reorder, or use the arrows.
What is the output of this code using a custom module?
1import math
2angle = 3.1415926535
3result = round(math.cos(angle), 1)
4print(result)What does this from...import code print?
1from math import sqrt
2value = sqrt(81)
3print(int(value))What is the single line of output?
1import json
2data = {"user": "Ana", "active": True}
3text = json.dumps(data)
4print("user" in text)What is the output related to search paths?
1import sys
2print(isinstance(sys.path, list))What is printed when importing from a package's __init__.py?
1package_name = "tools"
2print(package_name.upper())Find the bug in this code that tries to use a function from a module in the same package.
Click on the line(s) that contain the bug.
from .math_tools import add_numbers def total_price(prices): result = 0 for price in prices: result = add_number(result, price) return resultFind the bug in this code that serializes data to JSON.
Click on the line(s) that contain the bug.
import json def save_user(user_dict, file_obj): text = json.load(user_dict) file_obj.write(text) return textMatch each tool with what it primarily manages.
Click an item on the left, then click its match on the right. Click a matched item to unmatch.
Match the import style with what it provides.
Click an item on the left, then click its match on the right. Click a matched item to unmatch.
Complete the code to create a package shortcut in __init__.py that exposes selected utilities.
# utilities/__init__.pyfrom .string_tools import from .math_tools import __all__ = [, ]Click an option to fill blank 1:
Complete the code to create and use a virtual environment-friendly requirements file.
import subprocessdef export_requirements(env_python, output_file): command = [env_python, , , ] with open(output_file, "w", encoding="utf-8") as handle: subprocess.run(command, stdout=handle, check=True)Click an option to fill blank 1:
Click the line that directly controls which names are imported with from tools import *.
Click on the line to select.
import math __all__ = ["analyze", "summarize"] def analyze(data): return len(data) def summarize(data): return sum(data) / len(data)Click the line that activates a virtual environment's Python interpreter in this helper function.
Click on the line to select.
import subprocess def run_in_env(env_python, script_path): command = [env_python, script_path] return subprocess.run(command, check=True)