Computer Science - Class 12
Solutions to CBSE Sample Paper - Computer Science Class 12

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

Ask a doubt
Davneet Singh's photo - Co-founder, Teachoo

Made by

Davneet Singh

Davneet Singh has done his B.Tech from Indian Institute of Technology, Kanpur. He has been teaching from the past 14 years. He provides courses for Maths, Science, Social Science, Physics, Chemistry, Computer Science at Teachoo.