livepython.net

23. Python Program to Calculate and Format a Total Cost

MediumStrings

Overview

Format output using variables.

Problem Statement

Calculate and format a product's total cost.

Constraints:

  • Use product = "Apple", price = 0.99, quantity = 5
  • Calculate total cost (price × quantity)
  • Format output as: "5 Apples cost $4.95"

Input

  • No input required

Output

5 Apples cost $4.95

Learn this firstChapter 5 · Python Strings for Beginners: Join, Repeat and f-strings
solution.py
# write your code here

EXPECTED OUTPUT

15 Apples cost $4.95

YOUR OUTPUT

Press Run to see your output here. Lines are compared with the expected output.