Unit: Unit 4: Strings, Lists, and Tuples • Interactive Practice
Interactive Python programming tutorial and practice in your browser.
# Format numeric outputs using modern Python f-strings
item = "Laptop Charger"
price = 49.9
discount_rate = 0.15
discounted_price = price * (1 - discount_rate)
# Format floating-point numbers with 2 decimal places using :.2f
summary = f"Product: {item} | Price: ${discounted_price:.2f}"
print(summary)