ProgrammingHardTCS NQT · Infosys
What is printed?
What is printed?
print('Hello, World'.swapcase(), 'hello world'.title(), "it's here".capitalize(), 'ABC'.isupper())- A. hELLO, wORLD Hello World It's here True
- B. hELLO, wORLD Hello World It's here False
- C. Hello, Worlds Hello World It's here True
- D. hELLO, wORLD Hello World It's here Yes
Correct answer: A. hELLO, wORLD Hello World It's here True
swapcase flips each letter's case, title capitalises each word, and capitalize uppercases only the first character. isupper is True because the string has cased characters and none are lowercase.
More Python Programming questions
- What is printed? python print(float('9007199254740993') == 9007199254740993, int(float('9007199254740993')), int(9007199254740993.0))
- What is printed? python print(len('abc' 1000000 + ''), 'abc' in 'x' 10 + 'abc', 'ab' < 'abc', [1, 2] < [1, 2, 0])
- What is printed? python print(10 -1 == 0.1, 10 0.5 == 10 (1 / 2), int(10 0.5) 2 == 10, round(10 0.5 10 0.5, 9))
- What is printed? python from functools import cmptokey print(sorted(['10', '9', '2'], key=cmptokey(lambda a, b: int(a) - int(b))))
- What is printed? python print(1 << 31 >> 31, (1 << 31) >> 31 == 1, -1 >> 31, -231 >> 31)
- What is printed? python print('1' + '2' 3, '1' 2 + '2', len('ab' 0 + 'c' 3), 'x' 2 == 'xx')