ProgrammingHardTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
print(len({(i, j) for i in range(3) for j in range(3) if i <= j}))- A. 5
- B. 6
- C. 9
- D. 3
Correct answer: B. 6
The pairs with i <= j among 0, 1, 2 are (0,0), (0,1), (0,2), (1,1), (1,2) and (2,2), which makes 6 distinct tuples.
More Python Programming questions
- What is printed? python print(sum(1 for c in 'Hello World' if c.isupper()), 'Hello World'.count('o'))
- 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])