Quarry School

Pass an argument

Subject: Computing
Level 1 · FoundationsAbout 5 min read2 new terms
How this was estimated

Programmatic estimate. Rung levels, worked steps, prerequisites, terms and sentence length contribute to this level. It describes the lesson, not your ability.

Reading counts the whole lesson, including folded explanations, at 180 words a minute. Practice allows two minutes per item. These are planning assumptions; take the time you need.

AI estimate unavailable.

Path to here

Open the unit’s lesson list to follow the lesson order.

    Quick review (2 minutes)

    In plain words

    A printed invitation leaves a blank after the word Dear.

    Rule

    A parameter is a name in the parentheses of a def line, and an argument is a value in the parentheses of a call. For the calls in this unit, Python works out the arguments, ties them to the parameters in order and then runs the body. For the functions defined in this unit, a call with fewer arguments than parameters stops with a TypeError.

    Step

    1. Find the value in the body that should change from call to call.

    2. Give that value a name and write the name inside the parentheses of the def line. For two values, write two names with a comma between them.

    3. Use the names in the body where the values were.

    4. In each call, write the values inside the parentheses in the same order as the names.

    5. Trace a call by writing each parameter with the argument it received, then running the body with those values.

    Trap

    Arguments in the wrong order are the quiet mistake. label(3, "pens") is a legal call, and the program displays pens x 3. Check each call against the order of the names in the def line.

    A second slip is to put quotation marks around a parameter's name in the body. Quotation marks make text, so print("name") displays the word name for every guest. Write the name without quotation marks, or inside the braces of an f-string, to use the value it holds.

    1 In plain words

    A printed invitation leaves a blank after the word Dear. The printer makes one design, and each copy gets a different name written into the blank.

    A function can have blanks of its own. A parameter is a name written inside the parentheses of the def line. An argument is a value passed to a function in a call. It is written, or worked out from what is written, inside the call's parentheses.

    At a call, Python ties each parameter to an argument. With the calls in this unit the order decides: the first argument goes to the first parameter, the second to the second. Inside the body, a parameter is used like any other name.

    Remember one sentence: the parameter is the blank, and the argument is what fills it. To look them up, find parameter and argument in the glossary of the Python 3.13 documentation.

    2 Picture it

    PositionParameterArgumentfirstitem"pens"secondcount3

    A table for the call label("pens", 3). The first position ties the parameter item to the argument "pens". The second position ties the parameter count to the argument 3. The first row is marked.

    How the call label("pens", 3) fills the two parameters

    3 Why

    One function can serve many values because the body is written with names, and each call says what the names hold this time. The line greet("Ada") runs the body with name holding "Ada", and greet("Sam") runs the same body with name holding "Sam".

    Python works out each argument before the call begins. In label("cups", 2 + 2) the addition is done first, and the parameter count receives 4.

    A call has to supply an argument for each parameter of the functions in this unit. A call with too few stops the program with a TypeError.

    4 The rule

    A parameter is a name in the parentheses of a def line, and an argument is a value in the parentheses of a call.

    For the calls in this unit, Python works out the arguments, ties them to the parameters in order and then runs the body. For the functions defined in this unit, a call with fewer arguments than parameters stops with a TypeError.

    5 How

    1. Find the value in the body that should change from call to call.
    2. Give that value a name and write the name inside the parentheses of the def line. For two values, write two names with a comma between them.
    3. Use the names in the body where the values were.
    4. In each call, write the values inside the parentheses in the same order as the names.
    5. Trace a call by writing each parameter with the argument it received, then running the body with those values.

    6 Worked example

    Greet two guests with one function

    Python code
    def greet(name):
        print(f"Welcome, {name}")
    
    greet("Ada")
    greet("Sam")
    

    Standard input

    Empty

    Standard output

    Welcome, Ada
    Welcome, Sam
    

    Predict the two output lines first. Then save the code as greet.py and run the file. Each call ties the parameter name to its own argument.

    Pass two arguments in order

    Python code
    def label(item, count):
        print(f"{count} x {item}")
    
    label("pens", 3)
    label(3, "pens")
    

    Standard input

    Empty

    Standard output

    3 x pens
    pens x 3
    

    Predict the two output lines first. Then save the code as label.py and run the file. The second call gives the arguments in the other order, so item holds 3 and count holds the text. Python reports no error, and the label comes out the wrong way around.

    Leave an argument out

    Python code
    def greet(name):
        print(f"Welcome, {name}")
    
    greet()
    

    Standard input

    Empty

    Standard output

    Empty

    Exception TypeError

    Save the four lines as missing.py and run the file. The call supplies no argument for name, so Python stops with a TypeError before the body runs.

    Trace

    Trace the call label("pens", 3) of the label program
    InstructionitemcountOutputExplanation
    def label(item, count):unsetunset—The def line stores the body. The parameters hold nothing yet: they get values at a call.
    label("pens", 3)"pens"3—The first argument goes to item and the second to count.
    print(f"{count} x {item}")"pens"33 x pensThe body runs with those two values.

    7 The trap

    Arguments in the wrong order are the quiet mistake. label(3, "pens") is a legal call, and the program displays pens x 3. Check each call against the order of the names in the def line.

    A second slip is to put quotation marks around a parameter's name in the body. Quotation marks make text, so print("name") displays the word name for every guest. Write the name without quotation marks, or inside the braces of an f-string, to use the value it holds.

    Quick checks

    Quick check 1 of 2

    The label program defines label(item, count) as in the worked example. What does this call display?

    Python code
    label("cups", 2 + 2)
    Show the steps and the answer
    Answer

    It displays 4 x cups.

    Why: Python works out 2 + 2 before the call, so count receives 4, and item receives the text cups.

    Source: Python Software Foundation, Python 3.13 Language Reference, 6.3.4 Calls

    Quick check 2 of 2

    Predict what this program displays. The program reads no input.

    Python code
    def seat(row, number):
        print(f"Row {row}, seat {number}")
    
    seat(7, 2)
    seat(2, 7)
    Show the steps and the answer
    Answer

    It displays Row 7, seat 2 and then Row 2, seat 7.

    Why: The first argument of each call goes to row and the second to number. The two calls give the same numbers in different orders.

    Source: Python Software Foundation, Python 3.13 Language Reference, 6.3.4 Calls

    Sources

    1. Python 3.13 Glossary: parameter. Python Software Foundation. Python Software Foundation License Version 2. Read 1 Dec 2026.
    2. Python 3.13 Glossary: argument. Python Software Foundation. Python Software Foundation License Version 2. Read 1 Dec 2026.
    3. Python 3.13 Language Reference, 6.3.4 Calls. Python Software Foundation. Python Software Foundation License Version 2. Read 1 Dec 2026.
    4. Python 3.13 Tutorial, 3.1.2 Text. Python Software Foundation. Python Software Foundation License Version 2. Read 1 Dec 2026.