ProgrammingModerateTCS NQT · Infosys
What is printed?
What is printed?
print(list(range(2, 20, 5)), list(range(-1, -10, -4)))
- A. [2, 7, 12, 17, 22] [-1, -5, -9]
- B. [2, 7, 12, 17] [-1, -5, -9, -13]
- C. [2, 7, 12] [-1, -5]
- D. [2, 7, 12, 17] [-1, -5, -9]
Correct answer: D. [2, 7, 12, 17] [-1, -5, -9]
range(2, 20, 5) includes starts up to but not including 20, and range(-1, -10, -4) steps down from -1 and stops before -10.
More Python Programming questions
- What is printed? python print(len(str(71000)), 71000 % 10)
- What is printed? python print(10 -3 1000 == 1, 10 -3 1000)
- What is printed? python print(int('12' 2) + int('3' 2), len({'x' n for n in range(4)}))
- What is printed? python print(bin(6 & -6), bin(6 | -6), bin(6 ^ -6))
- What is printed? python print(hex(28 - 1), oct(29), bin(24))
- What is printed? python print(str(0.5), str(0.25 + 0.125), 0.1 + 0.25)