ProgrammingHardTCS NQT · Accenture
What is printed?
What is printed?
print('%s and %r' % ('a', 'a'))- A. 'a' or 'a'
- B. a and b
- C. s and 'a'
- D. a and 'a'
Correct answer: D. a and 'a'
%s uses str, which leaves a unquoted, while %r uses repr, which adds quotes around a.
More Python Programming questions
- What is printed? python print('-'.join(map(str, range(3, 0, -1))))
- What is printed? python print('abc'[-1:-4:-1], 'abc'[5:], 'abc'[-10:2])
- What is printed? python print(ord('A') + 1, chr(ord('a') - 32))
- What is printed? python print(divmod(7, -2), 7 % -2)
- What is printed? python print(sum([[1], [2, 3]], []))
- What is printed? python x = (1, [2]) x[1].append(3) print(x)