ProgrammingHardTCS NQT · Infosys
What is printed?
What is printed?
print('Ab'.swapcase(), 'ab'.capitalize() == 'Ab', 'AB'.lower() == 'ab', 'a b'.title())- A. aB True False A b
- B. AB True True A C
- C. aB False True A B
- D. aB True True A B
Correct answer: D. aB True True A B
swapcase turns Ab into aB, and capitalize gives Ab for ab. lower() of AB is ab, and title() capitalises each word of a b.
More Python Programming questions
- What is printed? python print(3 > 2 > 1, 3 > 2 and 2 > 1, (3 > 2) + (2 > 1))
- What is printed? python print(sorted([0.5, 1, True, False]), max(0.5, 1, True))
- What is printed? python print('%s|%s' % ('a', 'b'), 'ok', '%5.1f%%' % 99.55)
- What is printed? python print(len(set('aabbcc')), sorted(set('cba')), 'abc'.index('b') + 'abc'.count('b'))
- What is printed? python print(1000000 1000000 == 1012, 0.1 0.1 100 == 1, round(0.1 0.1 100, 10) == 1.0, 2 0.5 == 2 (1 / 2))
- What is printed? python print(sum(range(0, 101, 5)), len(range(0, 101, 5)))