What will the following expression be evaluated to in Python?

print(15.0 / 4 + (8 + 3.0))

(a) 14.75

(b)14.0

(c) 15

(d) 15.5

 

Answer:

Question 14 -Teachoo.png

So, the correct answer is (a) 14.75

 

Explanation:

Step 1: In python, the content inside the parentheses is evaluated first. So the expression becomes (15.0 / 4 + (11.0))

Step 2: ‘/’ takes precedence over ‘+’. So the expression becomes (3.75 + 11.0)

Step 3: The final evaluation is done and the answer is 14.75

Remove Ads
Davneet Singh's photo - Co-founder, Teachoo

Made by

Davneet Singh

Davneet Singh is an IIT Kanpur graduate and has been teaching for 16+ years. At Teachoo, he breaks down Maths, Science and Computer Science into simple steps so students understand concepts deeply and score with confidence.

Many students prefer Teachoo Black for a smooth, ad-free learning experience.