ProgrammingHardTCS NQT · Infosys
What is printed?
What is printed?
print(int(' 3 ') + 1, int('3\n') * 2, float(' 2.5\t') * 2)- A. 4 6 2.5
- B. 4 3 5.0
- C. 5 6 5.0
- D. 4 6 5.0
Correct answer: D. 4 6 5.0
int and float ignore surrounding whitespace, including newlines and tabs. Adding 1 to 3 gives 4, and doubling 3 gives 6. Doubling 2.5 gives 5.0.
More Python Programming questions
- What is printed? python print(len('é'.encode('utf-8').decode('latin-1')), 'é'.encode('utf-8').decode('latin-1'))
- What is printed? python print(sum(1 for c in 'Mississippi' if c in 'aeiouAEIOU'), 'Mississippi'.lower().count('s')…
- What is printed? python print([] == [] or 1 / 0, [] and 1 / 0, 0 or 1 and 2)
- What is printed? python print(3 % 2 == 1 and 4 % 2 == 0, 3 // 2 == 1 or 1 / 0)
- What is printed? python print(f'{"":>3}|', f'{"x":^3}|', f'{None!s:>6}|')
- What is printed? python from functools import lrucache @lrucache(maxsize=None) def t(n): if n == 0: return 0 if n < 3: return 1 return t(n…