ProgrammingHardProduct-company MCQ pattern
What is printed?
What is printed?
n = [1] print(1 in n == True, (1 in n) == True, 0 < 1 in n)
- A. True True True
- B. False True False
- C. False True True
- D. True True False
Correct answer: C. False True True
in, == and < are all comparison operators, so they chain like a < b < c. 1 in n == True means (1 in n) and (n == True); a list never equals True, so the result is False. With brackets it is simply True == True. 0 < 1 in n means (0 < 1) and (1 in n), both True.
More Python Programming questions
- What is printed? python class P: slots = ("x",) def init(self): self.x = 1 p = P() try: p.y = 2 except AttributeError: print("AE", end="…
- What is printed? python class T: def init(self): self.c = 0 @property def c(self): return self.c @c.setter def c(self, v): self.c = max(0…
- What is printed? python def acc(): total = 0 while True: try: x = yield total except ValueError: total = 0 continue if x is None: break…
- What is printed? python class Base: def init(self): self.log = ["Base"] class L(Base): def init(self): super().init() self.log.append("L")…
- What is printed? python class D: def get(self, obj, typ): return "desc" class DD(D): def set(self, obj, v): pass class C: a = D() b = DD()…
- What is printed? python class K: def init(self, v): self.v = v def hash(self): return hash(self.v) def eq(self, o): return self.v == o.v k…