In Python, a function may contain default arguments. According to Python’s…
2026
In Python, a function may contain default arguments. According to Python’s syntax rules, which of the following function headers (prototypes) correctly defines a function with default arguments?
- A.
def SimpleInterest(P=100, R, T):
- B.
def SimpleInterest(P, R=10, T):
- C.
def SimpleInterest(P, R, T=1):
- D.
def SimpleInterest(P=100, R, T=1):
Attempted by 422 students.
Show answer & explanation
Correct answer: C
The correct answer is Option C.
In Python, default arguments must always be placed after non-default arguments in a function definition. This is a strict syntax rule.
Option C:
def SimpleInterest(P, R, T=1):
Here, P and R are non-default arguments, and T is a default argument placed at the end, which is correct.
Other options are incorrect because they place default arguments before non-default ones, which violates Python syntax rules.