ProgrammingHardProduct-company MCQ pattern
What is printed?
What is printed?
print(1 < 2 > 1.5, 3 > 2 == 2, (3 > 2) == 2)
- A. True True False
- B. True False False
- C. True True True
- D. False True True
Correct answer: A. True True False
Comparisons chain: 1 < 2 > 1.5 means (1 < 2) and (2 > 1.5), which is True. 3 > 2 == 2 means (3 > 2) and (2 == 2), which is True. With brackets, (3 > 2) == 2 compares True with 2, i.e. 1 == 2, which is False.
More Python Programming questions
- What is printed? python a = [1, 2, 3] b = a a = a + [4] b += [5] print(a, b)
- What is printed? python print(-2 2, (-2) 2, 2 -1)
- What is printed? python print(0 or [] or "x", 1 and 0 and 5, None or 0)
- What is printed? python x = [1, 2] g = (n 10 for n in x) x.append(3) x = [7] print(list(g))
- What is printed? python class Bag: items = [] def add(self, v): self.items.append(v) a, b = Bag(), Bag() a.add(1); b.add(2) print(a.items…
- What is printed? python class A: def who(self): return "A" class B(A): def who(self): return "B" + super().who() class C(A): def…