ProgrammingModerateTCS NQT · Accenture
What is printed?
What is printed?
print(repr('ab' * -1), [1] * 0, 'a' * 3 == 'aaa')- A. 'ab' [] True
- B. '' [] True
- C. '' [1] True
- D. '' [] False
Correct answer: B. '' [] True
Multiplying by a negative count gives an empty sequence, and multiplying by zero also gives an empty list. 'a' * 3 equals 'aaa'.
More Python Programming questions
- What is printed? python print(all([]), any([]), all([0, 1]), any([0, '']))
- What is printed? python print([3, 1].sort() or 'x', sorted([3, 1]) == [1, 3])
- What is printed? python try: try: 1 / 0 except ZeroDivisionError: raise ValueError('bad') except ValueError as e…
- What is printed? python print(sorted([(1, 2), (1,), (0, 9, 9)]))
- What is printed? python print('abcabc'.find('c', 3, 5), 'abcabc'.rfind('a', 0, 4))
- What is printed? python d = {'a': {'b': 1}} print(d.get('a', {}).get('c', 0), d.get('x', {}).get('b'), d['a'].get('b'))