Skip to the content

Parameters

Python · Unit 4: Functions

A parameter is a variable the function receives when you call it. If there are several, commas separate them.

The value you pass in the call is called an argument.

def area(base, height):
    return base * height

print(area(4, 3))

Prints

12

The rest of the explanation is in the lesson, which is part of the full plan.

Exercises in this lesson

You do them in the app, which checks them on the spot and explains why.

  1. 1. Complete the code

    Fill in the call to work out the area of a 5 by 2 rectangle.

  2. 2. Multiple choice

    In def total(price, quantity):, what are price and quantity?

  3. 3. Predict the output

    What does this code print?

  4. 4. Predict the output

    What does this code print?

  5. 5. Find the bug

    This program should print what 3 coffees at 4 cost. Which line has the error?

  6. 6. Predict the output

    What does this code print?

  7. 7. Complete the code

    Fill in the blank so it prints "Ava is from Austin".

  8. 8. Find the case that fails

    fits(width, space) should give True if a couch fits in the space, including when it measures exactly the same. Which call makes it fail?

  9. 9. Put the lines in order

    Put in order the function that splits a 200 check among 4 people.

  10. 10. Predict the output

    What does this code print?

Do this lesson

It opens in your browser. This lesson is part of the full plan; the first unit of each course is free.

See all lessons →