ProgrammingHardTCS NQT · Wipro pattern
What is printed?
What is printed?
print(list(map(int, '1 2 3'.split())), list(map(str.upper, 'ab')), sum(map(int, '9' * 3)) % 7)
- A. [1, 2, 3] ['a', 'c'] 6
- B. [1, 2, 3] ['A', 'B'] 5
- C. [1, 2] ['A', 'B'] 6
- D. [1, 2, 3] ['A', 'B'] 6
Correct answer: D. [1, 2, 3] ['A', 'B'] 6
Each map applies the function to every item, and the digits 9 + 9 + 9 total 27, which is 6 mod 7.
More Python Programming questions
- What is printed? python print('%.3g' % 0.0001234, '%.3g' % 123456.0, '%g' % 1e-5, '%G' % 1e-10)
- What is printed? python print(max([1, 2], [1, 2, 0]) == [1, 2, 0], min((1, 'a'), (1, 'b')), sorted([(1, 'b'), (1, 'a')])[0][1])
- What is printed? python print(3 [0] == [0, 0, 0], [0] 3 is [0] 3, 'a' in 'abc' in 'abcdef')
- What is printed? python print(sum([1, 2, 3]) / 2 // 1, 7 // 2 / 2, divmod(7.0, 2)[0] == 7 // 2)
- What is printed? python print('{:^6}'.format('ab'), '{:<4}'.format(1), '{:>3}|{:<3}|'.format('a', 'b'))
- What is printed? python print('a' < 'b' < 'c', 'b' > 'a' and 'b' > 'c')