CBSE Class 11 Computer Science Question 5 of 42

Practice Paper — Question 5

Back to all questions
5
Question

Question 5

What will be the output of the following code?

import math
x = 100
print(x>0 and math.sqrt(x))
  1. True
  2. 1
  3. 10
  4. 10.0
Answer

10.0

Reason — The code first imports the math module to access mathematical functions. It then assigns the value 100 to the variable x. The print statement checks whether x > 0, which is True because x is 100. Since the and operator is used, and the first condition is True, the code proceeds to evaluate math.sqrt(x), which calculates the square root of x. The square root of 100 is 10.0, so the print statement outputs 10.0.