CodingNeed.

1 · First steps · 8 MIN

Calculate a total

Expressions calculate values.

* multiplies numbers. Multiplication has priority over addition; parentheses make grouping explicit. A dictionary holds named values such as input["price"]. These examples use whole currency units.

A shopping receipt multiplies each item price by its quantity before calculating a total.

Read the example

price = 4
quantity = 3
print(price * quantity)
Check the expected output
12

Your challenge

Return input["price"] multiplied by input["quantity"]. Input is an object with both numbers.

Common trap

Use dictionary key access, not input.price.

Next lesson: Choose a path →

Essential cookies keep your account signed in. Optional analytics is not configured on this site. Your choice does not affect access to lessons.

Read the Privacy Policy. You can change this choice in the footer.