Test Index

Functions in Python Get it on Google PlayDownload on the App Store CBSE Board Videos

© examsnet.com
Question : 11 of 23
Marks: +1, -0
State True or False :
While defining a function in Python, the positional parameters in the function header must always be written after the default parameters.
[CBSE 2024 Set 4]
Solution:  
Concept:
In a function header, parameters without default values (positional / required parameters) must come first, and parameters with default values come after them.
Explanation:
def area(l, b=10):      # valid
return l * b
def area(l=10, b): # SyntaxError: non-default argument follows default argument
return l * b
So the statement says the opposite of the rule: positional parameters must be written before the default parameters, never after them. Hence the statement is False.
Answer:
Option B (False)
© examsnet.com
Advertisements
Go to Question: