ProgrammingHardTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
lines = ['3 4', '10 20']
pairs = [tuple(map(int, ln.split())) for ln in lines]
print(pairs, sum(a * b for a, b in pairs))
  1. A. [(34,), (1020,)] 212
  2. B. [(3, 4), (10, 20)] 212
  3. C. [(3, 4), (10, 20)] 230
  4. D. [(3, 4), (10, 20)] 224

Correct answer: B. [(3, 4), (10, 20)] 212

Each line is split into two integers. 3 * 4 is 12 and 10 * 20 is 200, which sum to 212.

More Python Programming questions

Exams that ask this topic