Problem 120189 · easy · Level 01 Prerequisites & Setup

Receipt Line Item

functions · f-strings · arithmetic · string formatting

Write receipt_line(item, qty, unit_price) that returns one line of a receipt in exactly this form:

<item> x<qty> @ $<unit_price> = $<line total>

Both prices must be shown with two decimal places.

Examples

Input:  item = "Apples", qty = 3, unit_price = 0.5
Output: "Apples x3 @ $0.50 = $1.50"

Constraints

  • 0 <= qty <= 10**4, 0 <= unit_price <= 10**4; item is non-empty.

Goals

  • Combine text, integers and formatted floats in one f-string
  • Show prices with two decimals
Starting Python…