Exam GPYC All QuestionsBrowse all questions from this exam
Question 7

When the following program `question.py` is executed with Python what is the output?

    Correct Answer: C

    The code provided in the image is incorrect because functions in Python are case-sensitive. The function 'i' is defined with a lowercase 'i', but the call is made to 'I' with an uppercase 'I', which is not defined. This results in a NameError, indicating that 'I' is not defined. Therefore, the error can be described as a function override issue where the function 'i' is assigned but not called correctly.

Discussion
AZIrvThoOption: C

When the code is written correctly: def i (i): i=5 return i i = i (10) print(i) The response is 5, but in the exam question, the code is written incorrectly. So, shouldn't the answer be "C" noting that "i" cannot be called because of the syntax error?

VenudharOption: B

The option is B

natynat60Option: B

I is not defined. So it is an error (NameError: name 'I' is not defined) and I think it should be: def i(i): i=5 return i i=i(10) print(i) 5 #and yes the result is 5