Skip to content
Exercises · Q3

Q.Write logical expressions corresponding to the following statements in Python and evaluate the expressions (assuming variables num1, num2, num3, first, middle, last are already having meaningful values):

a) The sum of 20 and –10 is less than 12.
b) num3 is not more than 24.
c) 6.75 is between the values of integers num1 and num2.
d) The string ‘middle’ is larger than the string ‘first’ and smaller than the string ‘last’.
e) List Stationery is empty.
Yanam CbseNCERTSubjective· 3mImportance★★★★★est
61% · 30/49 Questions
✓ Free question

Each statement translates into a relational/chained-comparison expression; with the natural sample values (num1=5, num2=10, num3=30, the Gandhi name parts, a 3-item stationery list) they evaluate to True, False, True, False, False.

The idea — Boolean expressions. Relational operators (<, <=, ==) return True/False; Python allows chained comparisons (a < x < b), and strings compare lexicographically by Unicode code points. Since the question says the variables "already have meaningful values", we must pick and state an assumption to evaluate:

num1, num2, num3 = 5, 10, 30
first, middle, last = 'Mohandas', 'Karamchand', 'Gandhi'
stationery = ['Paper', 'Gel Pen', 'Eraser']

The expressions and their evaluation

PartExpressionEvaluationResult
a20 + (-10) < 1210 < 12True
bnum3 <= 2430 <= 24False
cnum1 < 6.75 < num25 < 6.75 and 6.75 < 10True
dfirst < middle < last'Mohandas' < 'Karamchand' → False (short-circuits)False
estationery == [] (or len(stationery) == 0)3-element list vs emptyFalse

Notes

  • (b) "not more than 24" = "less than or equal to 24", i.e. num3 <= 24; equivalently not (num3 > 24).
  • (c) "6.75 is between num1 and num2" reads perfectly as the chained comparison num1 < 6.75 < num2.
  • (d) "middle is larger than first and smaller than last" is middle > first and middle < last, i.e. the chain first < middle < last. Lexicographically 'K' (75) < 'M' (77), so 'Karamchand' is smaller than 'Mohandas' and the expression is False.
  • (e) an empty-list test can also be written idiomatically as not stationery.
Watch out

String comparison is by Unicode order, not alphabet intuition: all upper-case letters sort before all lower-case ones ('Z' < 'a'). With mixed-case data that surprises people.

✓Final answer

a) 20 + (-10) < 12 → True; b) num3 <= 24 → False; c) num1 < 6.75 < num2 → True; d) first < middle < last → False; e) stationery == [] → False (under the stated sample values).

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.