Purchase Cost
Programming Basics · Python
TASK
Problem
Given integer item price `price` and quantity `count`, print the total cost.
EXAMPLE
Example
120 4
480
LIMITS
Constraints
Quantities, prices, and balances are integers from 0 to 10^9; other integer inputs have absolute value at most 10^9.
LEARN
Theory for this problem
+
`input()` reads data entered by the user. The result of `input()` is initially a string. `split()` separates one input line into individual values using spaces. `map()` applies the specified conversion to each input value. The `*` operator multiplies numbers. `print()` displays the program result. Print only what the problem statement requires.
**Connection to this task.** The `*` operator multiplies numeric values. In formulas it naturally models repeated contribution, such as price × quantity, speed × time, or side × side. The expression `price * count` shows how this idea is applied to the task data.
NEED HELP?
Hints
+
['Total cost is item price multiplied by quantity.']
ANSWER
Solution
+
price, count = map(int, input().split()) result = price * count print(result)