Default parameters and positional parameters are two ways of defining and passing parameters in Python functions.

Default Parameters

Default parameters are parameters that have a default value assigned to them in the function definition. This means that if you don’t pass an argument for that parameter when you call the function, it will use the default value instead.  

For example, in the function def greet(name, message="Hello"):, message is a default parameter with the value "Hello". You can call this function with one or two arguments, like this:

greet("Alice") # prints Hello Alice

greet("Bob", "Hi") # prints Hi Bob

Positional Parameters

Positional parameters are parameters that are identified by their position or order in the function definition and call. This means that you have to pass the arguments in the same order as the parameters when you call the function. 

For example, in the function def add_two_numbers(a, b):, a and b are positional parameters. You have to call this function with two arguments, in the same order as the parameters, like this:

add_two_numbers(10, 20) # returns 30

add_two_numbers(20, 10) # returns 30

add_two_numbers(10) # error: missing argument

add_two_numbers(a=10, b=20) # error: unexpected keyword argument

Go Ad-free
Davneet Singh's photo - Co-founder, Teachoo

Made by

Davneet Singh

Davneet Singh has done his B.Tech from Indian Institute of Technology, Kanpur. He has been teaching from the past 14 years. He provides courses for Maths, Science, Social Science, Physics, Chemistry, Computer Science at Teachoo.