CBSE Class 11 Computer Science Question 100 of 173

Data Handling — Question 29

Back to all questions
29
Question

Question 29

Evaluate the following for each expression that is successfully evaluated, determine its value and type for unsuccessful expression, state the reason.

(a) len("hello") == 25/5 or 20/10

(b) 3 < 5 or 50/(5 - (3 + 2))

(c) 50/(5 - (3 + 2)) or 3 < 5

(d) 2 * (2 * (len("01")))

Answer

(a) len("hello") == 25/5 or 20/10
 ⇒ 5 == 25/5 or 20/10
 ⇒ 5 == 5 or 2
 ⇒ True or 2
 ⇒ True

The type of result is Boolean.

(b) 3 < 5 or 50/(5 - (3 + 2))
 ⇒ True or 50/(5 - (3 + 2))   [∵ first operand is True, second operand is not evaluated so no division by 0 error happens]
 ⇒ True

The type of result is Boolean.

(c) 50/(5 - (3 + 2)) or 3 < 5
 ⇒ 50/(5 - 5) or 3 < 5
 ⇒ 50/0 or 3 < 5
 ⇒ Division by Zero Error

As the denominator of or operator's first operand is 0, Division by Zero error occurs.

(d) 2 * (2 * (len("01")))
 ⇒ 2 * (2 * 2)
 ⇒ 2 * 4
 ⇒ 8

The type of result is Integer.

Answer