A project contains a Python module named local_rates.py whose entire contents are shown below:
fee = 5
In a fresh session, a booking program then runs this code successfully:
import local_rates as local from local_rates import fee as quoted_fee local.fee = 7
Which statements are true immediately afterward? Select every true statement. Assume no other imports or assignments occur.
print(quoted_fee) prints 5.
print(quoted_fee) prints 7.
print(fee) prints 5.
print(local.fee) prints 7.
Unlock full course notes by signing up
Track the names an import introduces
Each Python statement below runs separately in a fresh session. Enter the single name that the statement makes directly available for later use. Enter only the name, without parentheses or a dotted expression.
Calculate with two import forms
An art supplier can divide 37.5 kg of clay among cartons, each holding at most 8.0 kg. The following Python code calculates packing quantities. Here floor rounds down to an integer and ceil rounds up to an integer.
Find full, the number of completely filled cartons, and cartons, the total number needed, as exact integers. Find unused, the total unused capacity in kg, to one decimal place. Ignore carton mass and packing losses.
Locate the cause of an import-related error
A packing application can successfully import a local file named supplies.py, which contains only this assignment:
No module named missing_supplies is available. Each snippet below runs separately in a fresh Python interpreter. Enter the exception class raised by each snippet: ModuleNotFoundError, ImportError, or AttributeError.
Snippet A
Change the search path after importing
A school shop has two different files named pricing.py. Their complete contents are shown below.
File /class/shop/pricing.py
File /class/shared/pricing.py