Fundamentals

Pages in this section

  • Passing variables to a function
    Last edited: 2023-11-11

    When you pass a variable to a function , what does the function actually receive?

    First lets name things to make this a little simpler. The variable we pass to the function will be called the argument whereas the variable used by the function will be called the parameter.

    def function(parameter):
    	# The variable used by the function is called the parameter
    	...
    
    argument = ...
    
     The variable we pass to the function is called the argument
    
    function(argument)
    

    There are two main choices of what can happen to the argument when it gets passed into the parameter, it can be: