ProgrammingModerateGATE CS · Product-company placement
What is printed?
What is printed?
x = None print(x is None, x == None, bool(None), type(None).__name__, None is not False)
- A. True True False None True
- B. True True False NoneType True
- C. True False False NoneType True
- D. True True True NoneType False
Correct answer: B. True True False NoneType True
None is the single instance of NoneType; it is falsy but not equal to or identical with False, so `None is not False` is True.
More Python Programming questions
- What is printed? python class P: pass p = P() p.n = 1 p.n += 1 P.m = 10 q = P() q.m += 5 print(p.n, P.m, q.m, p.m, vars(q))
- What is printed? python def makeacc(): total = [] def add(x): total.append(x) return sum(total) def reset(): nonlocal total total = []…
- What is printed? python adders = [lambda x, n=n: x + n for n in range(3)] mults = list(map(lambda n: (lambda x: x n), range(3)))…
- What is printed? python def outer(): fs = [] for i in range(3): def f(j=None): return i if j is None else j fs.append(f) if i == 1: break…
- What is printed? python x = "global" def f(): return [x for in range(1)][0] def g(): x = "local" return (lambda: x)() def h(): return…
- What is printed? python try: r = [1 / x for x in [1, 0, 2]] except ZeroDivisionError: r = "partial?" g = (1 / x for x in [1, 0, 2]) out =…