ProgrammingModerateTCS NQT · Wipro pattern
What is printed?
What is printed?
print(18 // 4 if False else 'na', 'na' * 2 + 'ba')
- A. nana ba
- B. na nanaba
- C. na naba
- D. nanaba na
Correct answer: B. na nanaba
The conditional expression is False, so the first value is the string na. Multiplication binds tighter than +, so 'na' * 2 + 'ba' is nanaba, and the two values are printed separated by a space.
More Python Programming questions
- What is printed? python print(all(c.islower() for c in 'abc'), any(c.isdigit() for c in 'abc'), 'abc'.isascii() and 'é'.isascii())
- What is printed? python from collections import deque d = deque('abc') d.rotate(1) d.appendleft('z') print(''.join(d), d.pop())
- What is printed? python print(len(bin(255)), bin(255).count('0'), bin(-255).count('1'))
- What is printed? python print('%s' % 'x' 3, '%s' 2 % ('a', 'b'), '%s' % ('x' 3))
- What is printed? python print(3 'a' + 'b', 'c' 3 + 'd')
- What is printed? python print(int(3.7 10), int(0.7 10), 3.7 10 == 37, 0.7 10 == 7)