ProgrammingModerateTCS NQT · Wipro pattern
What is printed?
What is printed?
print(int('3' * 3) + int('4' * 2) * 2, '3' * 3 + '4' * 2 * 2)- A. 421 33344
- B. 331 3334444
- C. 422 3334444
- D. 421 3334444
Correct answer: D. 421 3334444
Multiplication binds tighter than +, so the number part is 333 + 44 * 2 = 421. For strings, '4' * 2 * 2 is '4444', so the concatenation is '333' followed by '4444'.
More Python Programming questions
- What is printed? python print(len('%s' % 1.0), len('%g' % 1.0), len(repr(1.0)), str(1e5), '%g' % 1e5, '%g' % 1e6)
- What is printed? python def f(s): return s[::-1] == s print(f('abba'), f('ab' 2), f(''), f('a'))
- What is printed? python print(True + True, str(True) + '1', str(None), str([None]), repr('None'))
- What is printed? python print(sorted([0.5, -0.0, 0.0, -1]))
- What is printed? python x = 10 16 print(float(x) == x, float(x + 1) == x, x + 1.0 == x, (x + 1) - x)
- What is printed? python print('%5s|%-5s|' % ('ab', 'cd'))