ProgrammingHardTCS NQT · Accenture
What is printed?
What is printed?
print(sorted({x % 4 for x in range(10)}))- A. [0, 1, 2, 3]
- B. [0, 1, 2]
- C. [1, 2, 3, 4]
- D. [0, 1, 2, 3, 4]
Correct answer: A. [0, 1, 2, 3]
The set comprehension keeps distinct remainders of 0 to 9 modulo 4, which are 0, 1, 2 and 3.
More Python Programming questions
- What is printed? python print('xxhixx'.strip('x') + '|' + 'abc'.strip('ac'))
- What is printed? python print(len(str(2100)), str(2100)[:5])
- What is printed? python print(sorted([[2, 'b'], [1, 'z'], [2, 'a']]))
- What is printed? python x = [1, 2, 3] y = x.copy() y.append(4) print(len(x), len(y), x is y)
- What is printed? python print('aaa' < 'b', 'abc' > 'abd')
- What is printed? python print(sum(1 for c in 'hello world' if c in 'aeiou'))