Study Guide

3.4.5 Add Parentheses CodeHS ANswers

3.4.5 Add Parentheses

The common answer is:

print(2 + 3 * (4 + 8))

This expression already correctly applies the order of operations, with parentheses ensuring that the addition inside them (4 + 8) is evaluated before being multiplied by 3, and finally adding 2. Here’s a breakdown:

  1. The expression inside the parentheses 4 + 8 is evaluated first, resulting in 12.
  2. Then, 3 is multiplied by the result (12), resulting in 36.
  3. Finally, 2 is added to 36, resulting in 38.

The output of print(2 + 3 * (4 + 8)) will therefore be:

38