What will be the output of the following code when x=20 : def my_function(x): return x + 5 print(x)
Created 2 years ago
180
Views
2
Comments
In Python courses -->Intermediate Module --> Quiz section on Function -->
The question is What will be the output of the following code when x=20 : def my_function(x): return x + 5 print(x)
Technically the function returns the value (x+5 which is 25) and whatever that comes next is not executed. That is the purpose of Return statement. Therefore the print(x) statement that comes after return x+5 statement is never executed at any point of the code. Thus the answer is 25.
But in the quiz section it shows 25 as wrong answer and 20 as the right answer.
So is it wrongly given or am I wrong?
Discussion needed !!