ProgrammingHardProduct-company MCQ pattern
What is printed?
What is printed?
print(len({x % 3 for x in range(10)}), sorted({x * x % 5 for x in range(5)}))- A. 3 [0, 1, 2]
- B. 3 [0, 1, 4]
- C. 2 [0, 1, 4]
- D. 3 [0, 4]
Correct answer: B. 3 [0, 1, 4]
x % 3 takes only the values 0, 1 and 2. The squares of 0 to 4 are 0, 1, 4, 4, 1, and reducing mod 5 keeps 0, 1 and 4.
More Python Programming questions
- What is printed? python print(list(range(-5, 5, 4)), list(range(5, -5, -4)), range(-1, -4, -1)[0])
- 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)