Question discussion

What is the output of the following Python code?a = [1, 2, 3] b = [4, 5, 6] print([x * y for x, y in zip(a, b)])

1760Medium DSSSB TGT Computer Science 0 replies

What is the output of the following Python code?

a = [1, 2, 3]
b = [4, 5, 6]
print([x * y for x, y in zip(a, b)])
  • A[4, 5, 6]
  • B[5, 7, 9]
  • C[4, 10, 18]
  • D[1, 4, 9]
Correct answer: C

Explanation

zip pairs the elements as (1,4), (2,5) and (3,6), and their products are 4, 10 and 18.

Discussion 0

Nobody has replied yet. Start the discussion!