nerdexam
Python_Institute

PCEP-30-02 · Question #293

What is the expected output of the following code? ``python 1 def func(x): 2 return 1 if x % 2 != 0 else 2 3 4 print(func(func(1))) ``

The correct answer is B. 1. See the full explanation below for the reasoning.

Question

What is the expected output of the following code?
1 def func(x):
2 return 1 if x % 2 != 0 else 2
3
4 print(func(func(1)))

Options

  • ANone
  • B1
  • CThe code is erroneous.
  • D2

How the community answered

(46 responses)
  • A
    17% (8)
  • B
    72% (33)
  • C
    9% (4)
  • D
    2% (1)

Community Discussion

No community discussion yet for this question.

Full PCEP-30-02 Practice