ProgrammingHardTCS NQT · Accenture
What is printed?
What is printed?
print('a,b,,c'.split(','), 'a b'.split())- A. ['a', 'b', '', 'c'] ['a', 'b']
- B. ['a', 'b', 'd'] ['a', 'b']
- C. ['a', 'b', '', 'c'] ['a', '', 'e']
- D. ['a', 'x', 'c'] ['a', 'b', 'c']
Correct answer: A. ['a', 'b', '', 'c'] ['a', 'b']
split with a comma keeps the empty field between the two commas. split without arguments splits on runs of whitespace and drops empty fields.
More Python Programming questions
- What is printed? python t = (1, 2) t += (3,) print(t, len(t))
- What is printed? python print(abs(-0), abs(-2.5), -(-3))
- What is printed? python print(hex(255), oct(8), bin(-5))
- What is printed? python print(chr(0x41), ord('n'))
- What is printed? python from collections import Counter a = [1, 1, 2, 3, 3] c = Counter(a) print(sum(c[x] c[4 - x] for x in c))
- What is printed? python def nlis(a): n = len(a) L = [1] n C = [1] n for i in range(n): for j in range(i): if a[j] < a[i]: if L[j] + 1 >…