+ 1
What the Argument?
I'm not understanding
3 Réponses
+ 8
def square(n): #n is a parameter
return n*n
print(square(4)) #4 is an argument
A parameter is the data embraced by () in the function definition. The argument is the value passed by the user when the function is called
+ 3
'Argument' is another word for 'parameter'...
When you call a function, mostly, you need to pass data to it, to do some tasks with it. You put them in parameters of your function as arguments in between the parenthesis ( round backets ) nexted the function name:
myFunction(anArgument, anotherParameter)
In first practical example of the Python course you've started, you'll do:
print("Hello world!")
... you are calling the function 'print' and passing to it the value "Hello world!" for displaying it at output.
The value passed is called as well 'parameter' as 'argument' :P
Redo first parts of course if needed, and feel free to test and practice the examples by clicking on 'try it yourself' links: you'll get it ;)
+ 1
what?