ProgrammingModerateTCS NQT · Wipro pattern
What is printed?
What is printed?
x = 1 x, y = x + 1, x * 10 print(x, y)
- A. 2 2
- B. 1 10
- C. 2 10
- D. 2 20
Correct answer: C. 2 10
The whole right-hand side is evaluated before anything is assigned, using the old x = 1: (1 + 1, 1 * 10) = (2, 10). Only then are x and y bound.
More Python Programming questions
- What is printed? python print(any([]), all([]), all([[]]))
- What is printed? python class C: n = 0 def init(self): C.n += 1 @classmethod def total(cls): return cls.n class D(C): pass D(); C(); D()…
- What is printed? python e = 5 try: 1 / 0 except ZeroDivisionError as e: pass try: print(e) except NameError: print("NameError")
- How many of the following statements about Python are correct? (i) A tuple that contains a list can be used as a dictionary key. (ii) A…
- What is printed? python a = [1, 2, 3] a += [4] a = a + [5] a.extend("67") print(a)
- What is printed? python x = [[0] 3] 2 y = [[0] 3 for in range(2)] x[0][1] = 5 y[0][1] = 5 print(x, y)