ProgrammingModerateTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
print(sum(1 for c in 'Hello World' if c.isupper()), 'Hello World'.count('o'))- A. 2 1
- B. 2 3
- C. 2 2
- D. 1 2
Correct answer: C. 2 2
Only the capital letters H and W are uppercase, which gives 2. 'o' appears once in Hello and once in World.
More Python Programming questions
- What is printed? python print(float('1e400'), -float('1e400'))
- What is printed? python print(str(1e16), str(1e15), str(123456789.0))
- What is printed? python print(0.1 3, 1.1 1.1)
- What is printed? python print(5 / 2, 5 // 2, -5 / 2, -5 // 2)
- What is printed? python s = 'abc' print(s 0 == '', s[5:] == '', s[-1] + s[0])
- What is printed? python print(divmod(-9, 2), divmod(9, -2))