Skip to content
beginner

Function Arguments and Return Values

Learning Python is a lot like learning how to give and follow instructions in real life. Imagine asking someone to make you a sandwich: you need to tell…

Published 2026-05-11Updated 2026-05-127 min read

Learning Python is a lot like learning how to give and follow instructions in real life. Imagine asking someone to make you a sandwich: you need to tell them what kind of bread, what fillings, and whether you want it toasted. In programming, functions are like those helpers—they can do things for you, but you need to give them the right information. That’s where function arguments and return values come in.

Understanding how to pass information into a function and get results back is a big step toward writing powerful and flexible Python code. Let’s break down these concepts and see how they can help you solve real problems as you learn Python.


What Are Function Arguments?

Function arguments are pieces of information you give to a function so it can do its job. Think of them as the ingredients you hand to your sandwich maker. Without them, your helper wouldn’t know what kind of sandwich you want!

Arguments make functions flexible. Instead of writing a new function for every situation, you can write one function that works with different inputs.

For example, imagine you want a function that says hello to someone. Instead of writing a new function for every name, you can create one function and give it the name as an argument.

Quiz Question 1

Question: What is the main purpose of using parameters in a Python function?

  • A) To allow the function to accept different input values each time it is called
  • B) To print information to the screen
  • C) To define the name of the function
  • D) To end the function early

Understanding Parameters and Arguments

It’s easy to mix up the words parameters and arguments. Here’s a simple way to remember the difference:

  • Parameters are the names you use in the function’s definition. They’re like empty boxes waiting to be filled.
  • Arguments are the actual values you give to the function when you use (call) it.

For example, when you define a function, you might write:

def greet(name):
    print("Hello, " + name + "!")

Here, name is a parameter. Later, when you call the function:

greet("Alice")

“Alice” is the argument. The parameter name gets filled with the argument “Alice” when the function runs.

Tip:
Parameters = Placeholders in the definition.
Arguments = Actual values you pass in.

Quiz Question 2

Question: Which of the following statements is true about parameters and arguments in Python?

  • A) Parameters and arguments are always the same thing
  • B) Parameters are used in the function definition; arguments are the values passed when calling the function
  • C) Arguments are only used in print statements
  • D) Parameters can only be numbers

How Functions Return Values

So, you’ve given your function some information—now what? Sometimes, you want your function to give something back. This is where return values come in.

A return value is the result a function sends back after it finishes its work. In Python, you use the return statement to give this value back.

For example:

def add(a, b):
    return a + b

When you call add(2, 3), the function returns the value 5. You can save this value in a variable:

result = add(2, 3)
print(result)  # This will print 5

Why are return values useful? They let you use the result of a function elsewhere in your program. Instead of just printing something, your function can send information back for you to use however you want.

Quiz Question 3

Question: What happens if you do not include a return statement in your Python function?

  • A) The function will return 0
  • B) The function will return None
  • C) The function will cause an error
  • D) The function will return the last value calculated

The Role of def in Functions

Every function in Python starts with the word def. This tells Python you’re defining a new function.

When you write:

def say_hello(name):
    return "Hello, " + name + "!"
  • def starts the function definition.
  • name is the parameter (the placeholder for an argument).
  • The return statement gives back the result.

If you’re new to writing functions, it’s a good idea to review how def works. Remember:

  • Use def to define a function.
  • List parameters in parentheses after the function name.
  • Use return to send a value back.

Quiz Question 4

Question: Why do we use the keyword def in Python?

  • A) To delete a function
  • B) To define a new function
  • C) To display output
  • D) To return a value

Why Arguments and Return Values Matter

Understanding python function arguments and return values is more than just a technical skill—it’s a way to make your code smarter and more adaptable.

Imagine you’re writing a program to calculate the total price of items in a shopping cart. With arguments, you can pass in different prices and quantities. With return values, your function can give you the total cost, which you can use for receipts, discounts, or anything else.

Here are some everyday tasks made easier with functions:

  • Calculating grades based on scores (arguments: scores; return value: grade)
  • Sending personalized messages (arguments: name, message; return value: formatted message)
  • Converting temperatures (arguments: temperature; return value: converted value)

The more you practice, the more confident you’ll become in using these building blocks for bigger projects—like web apps, games, or data analysis.


Check Your Understanding

Ready to see how much you’ve learned? Try these quick questions:

  1. What’s the difference between a parameter and an argument in Python?
  2. Why would you use a return value instead of just printing from a function?
  3. Write a simple function that takes two numbers as arguments and returns their product.

Take a moment to answer these questions. If you’re not sure, review the examples above and try writing your own functions!


Keep Practicing!

Learning how to use python function arguments and return values is a key step in your programming journey. These concepts let you write code that’s flexible, reusable, and ready for real-world challenges.

Keep experimenting with your own functions. Try passing in different arguments and using return values in creative ways. With each step, you’ll get closer to building the kinds of programs you dream about.

Happy coding!


Quiz Answer Key

Question 1

Correct answer: A) To allow the function to accept different input values each time it is called

Explanation: Parameters are placeholders in the function definition that let you pass in different arguments (values) when you call the function, making it flexible and reusable.


Question 2

Correct answer: B) Parameters are used in the function definition; arguments are the values passed when calling the function

Explanation: Parameters are the variable names listed in the function definition. Arguments are the actual values you provide when you call the function.


Question 3

Correct answer: B) The function will return None

Explanation: If you do not include a return statement, Python functions return None by default.


Question 4

Correct answer: B) To define a new function

Explanation: The keyword def is used to define a new function in Python.

Keep learning

Related tutorials

Continue with nearby Python topics and beginner-friendly explanations.

beginner7 min read

Defining Functions in Python

Are you tired of writing the same lines of code over and over? Do you wish there was an easier way to organize your programs and make them easier to read?…

Read tutorial
beginner8 min read

Importing Modules in Python

Learning Python is like opening a toolbox full of handy gadgets. Many of these gadgets are called modules. If you want to write real programs,…

Read tutorial
beginner8 min read

Practice Exercises: Functions

Are you ready to strengthen your Python skills? If you’ve learned how to define and use functions, it’s time to put that knowledge into action! Practice is…

Read tutorial