ProgrammingModerateTCS NQT · Wipro pattern
What is printed?
What is printed?
print('ab' * 2 == 'abab', 'ab' * 0 == '', 'a' * 2 + 'b' * 0 == 'aa', ('x' * 2).count('xx'))- A. True True True 1
- B. True True False 1
- C. False True True 1
- D. True True True 2
Correct answer: A. True True True 1
Repeating a string gives the same text as writing it out, and repeating zero times gives the empty string. Adding b * 0 adds nothing, and 'xx' occurs once in 'xx'.
More Python Programming questions
- What is printed? python print(int('٣٣') 2, '٣٣'.isdigit(), '٣٣'.isascii(), '3' == '٣')
- What is printed? python import math print(math.gcd(0, -5), math.gcd(-4, -6), math.lcm(0, 5), math.lcm(-4, 6))
- What is printed? python print(len('%.3f' % 260), '%.3f' % 260, '%.0f' % 1e20)
- What is printed? python print(round(1e16 + 2), round(9.5), round(10.5), round(-9.5))
- What is printed? python print(type(1 / 2).name, type(1 // 2).name, type(2 -1).name, type(2 0.5).name, type(True + 1).name)
- What is printed? python print(sorted(['10', '9', '1.5']), sorted(['10', '9', '1.5'], key=float))