Skip to content
Worked Examples · Example 3.7

Q.How will the following expression be evaluated?
15.0 / 4.0 + (8 + 3.0)

Uttar Pradesh UpmspTextbookSubjective· 2mImportance★★★★★est
28% · 7/25 Questions
🔒 Locked · start free trial →

You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.

Start your 14-day free trial to unlock the full solution →

This expression evaluates to 14.75 by applying operator precedence: parentheses first, then division (left-to-right), then addition.

Why operator precedence matters

When Python (or any programming language) encounters an expression with multiple operators, it doesn't simply evaluate left-to-right. Instead, it follows a strict hierarchy called operator precedence that determines which operations execute first. Think of it as the mathematical order of operations (PEMDAS/BODMAS) built into the language.

The precedence rules relevant here are:

  1. Parentheses ( ) — highest priority; always evaluated first
  2. Multiplication *, Division /, Floor Division //, Modulus % — equal priority among themselves, evaluated left-to-right
  3. Addition +, Subtraction - — lower priority, also left-to-right

Step-by-step evaluation

Let's trace through 15.0 / 4.0 + (8 + 3.0):

StepExpressionOperationResult
115.0 / 4.0 + (8 + 3.0)Evaluate parentheses: 8 + 3.015.0 / 4.0 + 11.0
215.0 / 4.0 + 11.0Division (higher precedence than +): 15.0 / 4.03.75 + 11.0
33.75 + 11.0Addition14.75

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.