In Python, the terms parameter
and argument
are used interchangeably. However, there is a slight distinction between these two terms. Parameters are the input variables bounded by parentheses when defining a function, whereas arguments are the values assigned to these parameters when passed into a function [or method] during a function call.
def team[name, project]: print[name, "is working on an", project] team["FemCode", "Edpresso"]
In the example
above, the function arguments are FemCode
and Edpresso
, whereas name
and project
are the function parameters.
def team[name, project]: print[name, "is working on an", project] team["FemCode", "Edpresso"]
def team[name, project]: print[name, "is working on an", project] team[project = "Edpresso", name = 'FemCode']
def team[name, project, members=None]: team.name= name team.project= project team.members= members print[name, "is working on an", project] team[name = "FemCode", "Edpresso"]
def team[name, project]: print[number, name,"are working on an", project] team["The two members of", "FemCode", "Edpresso"]
def team[*members]: for member in members: print[member] team["Abena", "Marilyn"]
Feel free to edit the code should you wish to add more arguments. You’ll see that executing the code will not throw a runtime error. This is because there is no limit to the number of arguments that can be passed into the function.
Below is an implementation of the combination of *args
and **kwargs
def team[*members, **features]: for member in members: print[member] for key,value in features.items[]: print["{}: {}".format[key,value]] team["Abena", "Marilyn", Name = "FemCode", Project = "Edpresso", Number = "Two Members"]
RELATED TAGS
python
parameter
argument
communitycreator
arbitrary