ProgrammingHardProduct-company MCQ pattern
What is printed?
What is printed?
print(list(range(-5, 5, 4)), list(range(5, -5, -4)), range(-1, -4, -1)[0])
- A. [-5, -1, 3] [5, 1, -3] -2
- B. [-5, -1, 3] [5, 2, -3] -1
- C. [-5, -1, 3] [5, 1, -3] -1
- D. [-5, -1, 3] [5, 1, -3] 0
Correct answer: C. [-5, -1, 3] [5, 1, -3] -1
range(-5, 5, 4) steps from -5 up to but not including 5, giving -5, -1, 3. A negative step counts down from its start, so range(-1, -4, -1) begins at -1.
More Python Programming questions
- What is printed? python print(int(-7 / 2), -7 // 2, int(7 / -2), 7 // -2)
- What is printed? python print(7 % 0.5, 7.25 % 0.5, -1 % 0.25)
- What is printed? python print(1 == 1.0 == True, 2 == 2.0 != 3.0)
- What is printed? python print(3 -2 9, (3 -2) 9 == 1.0, 3 -2 9 == 1)
- What is printed? python print(1000000 1000000 == 1012, 106 2 == 1012, 23 2 == 64)
- What is printed? python print(7 & -7, 7 | -7, 7 ^ -7, ~7 & 0xF)