ProgrammingModerateTCS NQT · Wipro pattern
What is printed?
What is printed?
print(3 * 'a' + 'b', 'c' * 3 + 'd')
- A. aaba cccd
- B. aaab dccc
- C. aaab cdcd
- D. aaab cccd
Correct answer: D. aaab cccd
Multiplication binds tighter than +, so 3 * 'a' + 'b' is aaab. The same rule gives cccd for the second string.
More Python Programming questions
- What is printed? python print(int(3.7 10), int(0.7 10), 3.7 10 == 37, 0.7 10 == 7)
- What is printed? python print(sorted([True, 2, 1.5, False, -1]))
- What is printed? python print(1 if [] == [] is True else 0, [] is [], () is ())
- What is printed? python print(len(str(float(10300))), str(float(1022))[:4], float(1022) == 1022)
- What is printed? python print(10 // 3, 10 % 3, divmod(10, 3), (10 // 3) 3 + 10 % 3)
- What is printed? python print([1, 2, 3].index(2), 'abc'.index('bc'), (1, 2).index(2), [1, 2, 3].count(4))