Check sibling questions

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:

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

  1. Computer Science - Class 12
  2. Solutions to CBSE Sample Paper - Computer Science Class 12

About the Author

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 and Computer Science at Teachoo