ProgrammingModerateTCS NQT · Infosys
What is printed?
What is printed?
print('-'.join('abc'), ''.join(map(str, [1, 2, 3])) == '123', ','.join([]) == '', 'x'.join(['', '']))- A. a-b-c True True x
- B. a-b-c False True x
- C. a-b-c True False x
- D. a-b-c True True xx
Correct answer: A. a-b-c True True x
join puts the separator only between items, so a join over two empty strings gives just the separator once. An empty list joined gives an empty string.
More Python Programming questions
- What is printed? python s = 'hello' print(s.find('l'), s.index('l', 3), s.rfind('l'), s.count('ll'), s.find('z'))
- What is printed? python print('%.2e' % 0.000123456, '%G' % 1e-5, '%g' % 1e-5, '%.3g' % 1234.5)
- What is printed? python print(max(3, 3.0), min(3.0, 3), max([2, 2.0]), type(max(2.0, 2)).name)
- What is printed? python print(sum([True, True, False]), sum([1.5, True]), True 3 + 0.5, sum([1, 2], 10))
- What is printed? python print(all([]), any([]), all([0, 1]), any([0.0, '']), all(x > 0 for x in [1, -1]))
- What is printed? python print(list(zip('ab', [1, 2, 3])), dict(zip('ab', [1, 2, 3])))