Editor

Generate a Personalized Email Greeting

Beginner · Write the code · from Python String Formatting: f-strings, format(), and % Operator

From the lesson: Python String Formatting: f-strings, format(), and % Operator

Imagine you're building a receipt for a coffee shop. You need to combine a product name, a price, and a quantity into one clean line. You could glue strings together with +, but it gets messy fast.

Read the lesson

Create these variables:

  • first_name = "Jordan"
  • items = 3
  • total = 89.95
  • Then use a multiline f-string (triple quotes) to print this exact message:

    Hi Jordan,
    
    Thank you for your purchase of 3 items.
    Your total is $89.95.
    
    Have a great day!

    Make sure the total shows exactly 2 decimal places.

    # Create the variables and print the email greeting

    More String Formatting exercises

    All Python exercises · 50 practice problems · Python Fundamentals quiz