ProgrammingHardTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
s = 'hello world'
print(s.title(), s.swapcase()[:5], s.replace('l', '', 2))- A. Hello World HELLO heo world
- B. Hello World HELLO heo wold
- C. Hello World HELLO heo worl
- D. Hello World hELLO he wold
Correct answer: A. Hello World HELLO heo world
title capitalises each word. swapcase on the first five characters gives HELLO. replace with count=2 removes only the first two l's, leaving 'heo world'.
More Python Programming questions
- What is printed? python a = [[0] 2 for in range(2)] b = [[0] 2] 2 a[0][1] = 5 b[0][1] = 5 print(a, b)
- What is printed? python print(divmod(7, 2), divmod(-7, 2), divmod(7.5, 2))
- What is printed? python def outer(): res = [] for i in range(3): res.append(lambda: i) return [f() for f in res] def outer2(): return…
- What is printed? python print(10 18 % 7, (10 18 + 2) // 4, -(2 63) // (2 62))
- What is printed? python lst = list(range(5)) lst[1:4] = [] try: lst[::2] = [9, 9] except ValueError: print('ValueError', lst)
- What is printed? python def dedupe(a): if not a: return 0 k = 1 for i in range(1, len(a)): if a[i] != a[k - 1]: a[k] = a[i] k += 1 return…