ProgrammingModerateTCS NQT · Wipro pattern
What is printed?
What is printed?
print(' '.join(['a', '', 'b']), ' '.join([]) == '', '-'.join('abc'), 'x'.join(['1', '2', '3']))- A. a b True a-b-c 1x2x4
- B. a b False a-b-c 1x2x3
- C. a b True a-b-c 1x2x3
- D. a b True abc 123
Correct answer: C. a b True a-b-c 1x2x3
Joining an empty list gives the empty string, and joining an empty element keeps two separators in a row. '-'.join('abc') puts a hyphen between each character.
More Python Programming questions
- What is printed? python from functools import reduce print(reduce(lambda a, b: a + b, ['x', 'y', 'z'], ''), reduce(lambda a, b: a b…
- What is printed? python print(0.1 + 0.2 > 0.3, 0.3 - 0.1 == 0.2, 0.2 + 0.2 == 0.4, 0.4 - 0.2 == 0.2)
- What is printed? python from collections import defaultdict d = defaultdict(int) for w in 'a b a c'.split(): d[w] += 1…
- What is printed? python print(sum([1e100, 1.0, -1e100]) == 1.0, sum([1, 1e100, -1e100]), 1e100 + 1.0 - 1e100)
- What is printed on the third line? python emp = [('Ravi', 30, 'IT'), ('Asha', 25, 'HR'), ('Meera', 30, 'HR'), ('Dev', 25, 'IT')] byage =…
- What is printed on the second line? python items = [3, -1, 2, -3, 1] print(sorted(items, key=abs)) print(sorted(items, key=abs…