ProgrammingModerateTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
a = [1, 2, 3] r = a.reverse() print(r, a)
- A. None [3, 2, 1]
- B. [3, 2, 1] [3, 2, 1]
- C. None [1, 2, 3]
- D. [3, 2, 1] [1, 2, 3]
Correct answer: A. None [3, 2, 1]
reverse() reverses the list in place and returns None, so r is None and a is changed.
More Python Programming questions
- What is printed? python t = (1) u = (1,) print(type(t).name, type(u).name, len(u))
- What is printed? python try: print(1.0 // 0.0) except ZeroDivisionError as e: print(e)
- What is printed? python print(int('0x1A', 16), int('1A', 16), int('0x1A', 0))
- What is printed? python print(len(str(10 400 // 3)))
- What is printed? python print(1000000 == 10 6, 0x1F, 1e3 == 1000)
- What is printed? python print(oct(64), hex(-255), bin(0))