nerdexam
Python_Institute

PCEP-30-02 · Question #387

What is the expected result of the following code? ``python def velocity(x=10): return speed * x speed = 10 new_speed = velocity() new_speed = velocity(new_speed) print(new_speed) ``

The correct answer is A. The code is erroneous and cannot be run. See the full explanation below for the reasoning.

Question

What is the expected result of the following code?
def velocity(x=10):
 return speed * x
speed = 10
new_speed = velocity()
new_speed = velocity(new_speed)
print(new_speed)

Options

  • AThe code is erroneous and cannot be run.
  • B20
  • C10
  • D30

How the community answered

(50 responses)
  • A
    84% (42)
  • B
    10% (5)
  • C
    2% (1)
  • D
    4% (2)

Community Discussion

No community discussion yet for this question.

Full PCEP-30-02 Practice