Python · Module 1
Answers and explanations · Values, names and types
Compare these references after your own attempt. You can read them at any time; they do not record a live model or vendor run.
Python · Module 1
Compare these references after your own attempt. You can read them at any time; they do not record a live model or vendor run.
Integer multiplication gives 700 cents. Floor division and remainder give 2 hours and 15 minutes. Conversion changes the kind of value; strip/lower changes text content.
# Reference answer. Attempt the exercise first.
quantity = 4
unit_price_cents = 175
total = quantity * unit_price_cents
print(total, "cents")
hours = 135 // 60
minutes_left = 135 % 60
raw = "7"
topic = " Data "
result = int(raw) + 3
normalized = topic.strip().lower()
assert total == 700
assert (hours, minutes_left) == (2, 15)
assert result == 10 and normalized == "data"
print("Module 1 checks passed")
Exit-check guide: The values "20", 20 and 20.0 have different types. int(2.9) discards the fractional part; it does not validate an integer count. The precedence answers are 14 and 20.