Skip to content
dreamcode
dreamcode
Map
Parameters
Lesson 21 of 77
+15 XP on finish
PYTHON BASICSChapter 4 · Functions

Inputs to functions

To make a function do different things depending on the situation, we give it parameters (inputs). When we call the function, we pass arguments (values) into those parameters.

Worked example

How it reads

  • def greet(name, time): defines two parameters, name and time
  • greet("Nova", "morning") calls the function, passing "Nova" into name and "morning" into time
  • The arguments must be passed in the same order as the parameters
Cloud tip: Parameters are the names listed in the function definition. Arguments are the actual values you send to the function when calling it.
main.py
PYTHON
real Python, runs in your browser
Console
Run your code to see its output here.
YOUR TURN

Add a third parameter c so add(1, 2, 3) prints 6. Call it with those three numbers.

Press Run to check your work.