What are mandatory parameters?

QuestionsQuestions8 SkillsProInstall and Verify HydraOct, 16 2025
0135

Mandatory parameters are the parameters that must be provided when calling a function or method. If these parameters are not supplied, the function will typically raise an error or exception, indicating that the required information is missing.

For example, in a function definition:

def add(a, b):
    return a + b

In this case, a and b are mandatory parameters. You must provide values for both when calling the function:

result = add(5, 3)  # This works

If you try to call the function without providing the required parameters:

result = add(5)  # This will raise a TypeError

In summary, mandatory parameters are essential for the function to execute correctly, and their absence will lead to errors.

0 Comments

no data
Be the first to share your comment!