Courseiva

PCEP Practice Question: Data Types, Variables, Basic I/O and Operators

A developer writes the following code to calculate a total price with tax:

price = 19.99 tax_rate = 0.08 total = price + price * tax_rate

print(round(total, 2))

What is printed?

⚠ Common exam trap

The trap here is forgetting operator precedence and adding price and tax_rate before multiplying, which would produce a very different and incorrect total.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

21.59

Multiplication has higher precedence than addition, so price * tax_rate is evaluated first, producing the tax amount. That tax is then added to the base price, and the round function limits the result to two decimal places. The combined total is approximately 21.5892 before rounding, which becomes 21.59 when rounded to two decimal places.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    1.6

    Why it's wrong here

    This value is only the tax amount, not the total. The code adds the tax to the original price before rounding, so the printed result must include the base price of 19.99. Reporting 1.6 ignores the addition of price and the final rounding of the combined total, so it does not match the script's output.

  • ✓

    21.59

    Why this is correct

    The expression price * tax_rate computes 19.99 * 0.08, which is approximately 1.5992. Adding that to the original price gives about 21.5892. The round function with two decimal places rounds this to 21.59, which is the value printed. This correctly applies multiplication before addition due to operator precedence.

  • ✗

    21.5892

    Why it's wrong here

    This is the unrounded total before the round function is applied. The script explicitly calls round(total, 2), which reduces the value to two decimal places. Printing 21.5892 would only happen if rounding were omitted, so this option describes an intermediate value rather than the final printed output.

  • ✗

    21.6

    Why it's wrong here

    This would be the result if the total were rounded to one decimal place instead of two. The round call specifies 2 as the number of digits, so the output should show two decimal places. The value 21.6 is also numerically different from the correctly rounded 21.59, so it is not what the script prints.

About these practice questions

One of 482 original PCEP practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official Python Institute exam blueprint

This PCEP practice question is part of Courseiva's free Python Institute certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the PCEP exam.