nerdexam
Python_Institute

PCEP-30-02 · Question #291

What is the expected output of the following code? ``python 1 x = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]] 2 3 def func(data): 4 res = data[0][0] 5 for d in data: 6 for d in data: 7 if res < d: 8 res =…

The correct answer is C. 4. See the full explanation below for the reasoning.

Question

What is the expected output of the following code?
1 x = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]]
2
3 def func(data):
4 res = data[0][0]
5 for d in data:
6 for d in data:
7 if res < d:
8 res = d
9 return res
10
11 print(func(x[0]))

Options

  • A8
  • B2
  • C4
  • D6
  • EThe code is erroneous.

How the community answered

(32 responses)
  • A
    3% (1)
  • B
    13% (4)
  • C
    72% (23)
  • D
    9% (3)
  • E
    3% (1)

Community Discussion

No community discussion yet for this question.

Full PCEP-30-02 Practice