🎓 EASYTUTORGUIDE · Complete Python Course

Very beginner → professional Python · 60 chapters · 900 topics

EasyTutorGuide

Chapter 17: Functions

Complete Python lesson for very beginners. Technical words are explained in simple language, and every outline topic includes a practical example, expected output, steps, and practice.

Python CourseVery Beginner Friendly15 TopicsExamples + Output20 Q&A
Chapter 17 · 15 topics
100%

Chapter Overview

This Python tutorial chapter covers Functions through 15 connected topics. Work through the examples in order, check the expected output, and complete the practice after each topic.

  • 17.1 Defining Functions
  • 17.2 Calling Functions
  • 17.3 Parameters
  • 17.4 Arguments
  • 17.5 Return Values
  • Plus 10 additional Python topics in this chapter.

17.1 Defining Functions

Defining Functions is part of Functions. In simple language, it means a reusable block of instructions.

It is one building block of functions and helps you write clearer, more predictable Python programs. For a very beginner, focus first on what goes in, what Python does, and what comes out; details become easier after you run a small example.

Technical words in simple language: Defining Functions (a reusable block of instructions).

Python / Practical Example

def greet(name):
    return f"Hello, {name}"

print(greet("Ava"))

Expected Output

Hello, Ava

Step-by-Step Explanation

  1. Define a function with def.
  2. A parameter receives the argument.
  3. return sends a result back to the caller.
Practice: Re-type the example for “Defining Functions”, change one safe input, predict the result before running it, and explain in one sentence why the result changed.

17.2 Calling Functions

Calling Functions is part of Functions. In simple language, it means a reusable block of instructions.

It is one building block of functions and helps you write clearer, more predictable Python programs. For a very beginner, focus first on what goes in, what Python does, and what comes out; details become easier after you run a small example.

Technical words in simple language: Calling Functions (a reusable block of instructions).

Python / Practical Example

def greet(name):
    return f"Hello, {name}"

print(greet("Ava"))

Expected Output

Hello, Ava

Step-by-Step Explanation

  1. Define a function with def.
  2. A parameter receives the argument.
  3. return sends a result back to the caller.
Practice: Re-type the example for “Calling Functions”, change one safe input, predict the result before running it, and explain in one sentence why the result changed.

17.3 Parameters

Parameters is part of Functions. In simple language, it means a name in a function definition that receives a value.

It is one building block of functions and helps you write clearer, more predictable Python programs. For a very beginner, focus first on what goes in, what Python does, and what comes out; details become easier after you run a small example.

Technical words in simple language: Parameters (a name in a function definition that receives a value).

Python / Practical Example

def add(a,b): return a+b
print(add(2,3))

Expected Output

5

Step-by-Step Explanation

  1. Read the example from top to bottom.
  2. Identify the value, object, or operation related to this topic.
  3. Change one small input and predict the result before running it.
Practice: Re-type the example for “Parameters”, change one safe input, predict the result before running it, and explain in one sentence why the result changed.

17.4 Arguments

Arguments is part of Functions. In simple language, it means a value supplied when a function is called.

It is one building block of functions and helps you write clearer, more predictable Python programs. For a very beginner, focus first on what goes in, what Python does, and what comes out; details become easier after you run a small example.

Technical words in simple language: Arguments (a value supplied when a function is called).

Python / Practical Example

def add(a,b): return a+b
print(add(2,3))

Expected Output

5

Step-by-Step Explanation

  1. Read the example from top to bottom.
  2. Identify the value, object, or operation related to this topic.
  3. Change one small input and predict the result before running it.
Practice: Re-type the example for “Arguments”, change one safe input, predict the result before running it, and explain in one sentence why the result changed.

17.5 Return Values

Return Values is part of Functions. In simple language, it means a Python idea used while learning functions.

It is one building block of functions and helps you write clearer, more predictable Python programs. For a very beginner, focus first on what goes in, what Python does, and what comes out; details become easier after you run a small example.

Technical words in simple language: Return Values (a Python idea used while learning functions).

Python / Practical Example

def add(a,b): return a+b
print(add(2,3))

Expected Output

5

Step-by-Step Explanation

  1. Read the example from top to bottom.
  2. Identify the value, object, or operation related to this topic.
  3. Change one small input and predict the result before running it.
Practice: Re-type the example for “Return Values”, change one safe input, predict the result before running it, and explain in one sentence why the result changed.

17.6 Multiple Return Values

Multiple Return Values is part of Functions. In simple language, it means a Python idea used while learning functions.

It is one building block of functions and helps you write clearer, more predictable Python programs. For a very beginner, focus first on what goes in, what Python does, and what comes out; details become easier after you run a small example.

Technical words in simple language: Multiple Return Values (a Python idea used while learning functions).

Python / Practical Example

def add(a,b): return a+b
print(add(2,3))

Expected Output

5

Step-by-Step Explanation

  1. Read the example from top to bottom.
  2. Identify the value, object, or operation related to this topic.
  3. Change one small input and predict the result before running it.
Practice: Re-type the example for “Multiple Return Values”, change one safe input, predict the result before running it, and explain in one sentence why the result changed.

17.7 Default Arguments

Default Arguments is part of Functions. In simple language, it means a value supplied when a function is called.

It is one building block of functions and helps you write clearer, more predictable Python programs. For a very beginner, focus first on what goes in, what Python does, and what comes out; details become easier after you run a small example.

Technical words in simple language: Default Arguments (a value supplied when a function is called).

Python / Practical Example

def greet(name="friend"):
    return f"Hello, {name}"
print(greet())
print(greet("Ava"))

Expected Output

Hello, friend
Hello, Ava

Step-by-Step Explanation

  1. Give the parameter a default value.
  2. Calling without an argument uses the default.
  3. Providing an argument overrides it.
Practice: Re-type the example for “Default Arguments”, change one safe input, predict the result before running it, and explain in one sentence why the result changed.

17.8 Keyword Arguments

Keyword Arguments is part of Functions. In simple language, it means a value supplied when a function is called.

It is one building block of functions and helps you write clearer, more predictable Python programs. For a very beginner, focus first on what goes in, what Python does, and what comes out; details become easier after you run a small example.

Technical words in simple language: Keyword Arguments (a value supplied when a function is called).

Python / Practical Example

def add(a,b): return a+b
print(add(2,3))

Expected Output

5

Step-by-Step Explanation

  1. Read the example from top to bottom.
  2. Identify the value, object, or operation related to this topic.
  3. Change one small input and predict the result before running it.
Practice: Re-type the example for “Keyword Arguments”, change one safe input, predict the result before running it, and explain in one sentence why the result changed.

17.9 Positional Arguments

Positional Arguments is part of Functions. In simple language, it means a value supplied when a function is called.

It is one building block of functions and helps you write clearer, more predictable Python programs. For a very beginner, focus first on what goes in, what Python does, and what comes out; details become easier after you run a small example.

Technical words in simple language: Positional Arguments (a value supplied when a function is called).

Python / Practical Example

def add(a,b): return a+b
print(add(2,3))

Expected Output

5

Step-by-Step Explanation

  1. Read the example from top to bottom.
  2. Identify the value, object, or operation related to this topic.
  3. Change one small input and predict the result before running it.
Practice: Re-type the example for “Positional Arguments”, change one safe input, predict the result before running it, and explain in one sentence why the result changed.

17.10 Arbitrary Arguments

Arbitrary Arguments is part of Functions. In simple language, it means a value supplied when a function is called.

It is one building block of functions and helps you write clearer, more predictable Python programs. For a very beginner, focus first on what goes in, what Python does, and what comes out; details become easier after you run a small example.

Technical words in simple language: Arbitrary Arguments (a value supplied when a function is called).

Python / Practical Example

def add(a,b): return a+b
print(add(2,3))

Expected Output

5

Step-by-Step Explanation

  1. Read the example from top to bottom.
  2. Identify the value, object, or operation related to this topic.
  3. Change one small input and predict the result before running it.
Practice: Re-type the example for “Arbitrary Arguments”, change one safe input, predict the result before running it, and explain in one sentence why the result changed.

17.11 *args

*args is part of Functions. In simple language, it means a Python idea used while learning functions.

It is one building block of functions and helps you write clearer, more predictable Python programs. For a very beginner, focus first on what goes in, what Python does, and what comes out; details become easier after you run a small example.

Technical words in simple language: *args (a Python idea used while learning functions).

Python / Practical Example

def total(*numbers):
    return sum(numbers)
print(total(2, 3, 4))

Expected Output

9

Step-by-Step Explanation

  1. *numbers collects extra positional arguments into a tuple.
  2. sum() adds them.
  3. This is useful when the count of arguments can vary.
Practice: Re-type the example for “*args”, change one safe input, predict the result before running it, and explain in one sentence why the result changed.

17.12 **kwargs

**kwargs is part of Functions. In simple language, it means a Python idea used while learning functions.

It is one building block of functions and helps you write clearer, more predictable Python programs. For a very beginner, focus first on what goes in, what Python does, and what comes out; details become easier after you run a small example.

Technical words in simple language: **kwargs (a Python idea used while learning functions).

Python / Practical Example

def show(**info):
    print(info)
show(name="Ava", age=20)

Expected Output

{'name': 'Ava', 'age': 20}

Step-by-Step Explanation

  1. **info collects keyword arguments into a dictionary.
  2. Keys come from argument names.
  3. Values come from the supplied argument values.
Practice: Re-type the example for “**kwargs”, change one safe input, predict the result before running it, and explain in one sentence why the result changed.

17.13 Function Documentation

Function Documentation is part of Functions. In simple language, it means a reusable block of instructions.

It is one building block of functions and helps you write clearer, more predictable Python programs. For a very beginner, focus first on what goes in, what Python does, and what comes out; details become easier after you run a small example.

Technical words in simple language: Function Documentation (a reusable block of instructions).

Python / Practical Example

def add(a,b): return a+b
print(add(2,3))

Expected Output

5

Step-by-Step Explanation

  1. Read the example from top to bottom.
  2. Identify the value, object, or operation related to this topic.
  3. Change one small input and predict the result before running it.
Practice: Re-type the example for “Function Documentation”, change one safe input, predict the result before running it, and explain in one sentence why the result changed.

17.14 Pure Functions

Pure Functions is part of Functions. In simple language, it means a reusable block of instructions.

It is one building block of functions and helps you write clearer, more predictable Python programs. For a very beginner, focus first on what goes in, what Python does, and what comes out; details become easier after you run a small example.

Technical words in simple language: Pure Functions (a reusable block of instructions).

Python / Practical Example

def add(a,b): return a+b
print(add(2,3))

Expected Output

5

Step-by-Step Explanation

  1. Read the example from top to bottom.
  2. Identify the value, object, or operation related to this topic.
  3. Change one small input and predict the result before running it.
Practice: Re-type the example for “Pure Functions”, change one safe input, predict the result before running it, and explain in one sentence why the result changed.

17.15 Function Design

Function Design is part of Functions. In simple language, it means a reusable block of instructions.

It is one building block of functions and helps you write clearer, more predictable Python programs. For a very beginner, focus first on what goes in, what Python does, and what comes out; details become easier after you run a small example.

Technical words in simple language: Function Design (a reusable block of instructions).

Python / Practical Example

def add(a,b): return a+b
print(add(2,3))

Expected Output

5

Step-by-Step Explanation

  1. Read the example from top to bottom.
  2. Identify the value, object, or operation related to this topic.
  3. Change one small input and predict the result before running it.
Practice: Re-type the example for “Function Design”, change one safe input, predict the result before running it, and explain in one sentence why the result changed.

Common Beginner Mistakes

  • Copying code without predicting what each line does.
  • Ignoring the first useful error message or traceback location.
  • Mixing tabs/spaces or changing indentation accidentally.
  • Using data of the wrong type for an operation.
  • Trying to learn many advanced variations before mastering one small working example.

Chapter Practice

  1. Choose three topics from this chapter and re-type their examples without copying and pasting.
  2. For each example, change one input and predict the output first.
  3. Explain five technical terms from this chapter in your own beginner-friendly words.
  4. Create one small program that combines at least two chapter topics.
  5. Keep notes about errors you made and what fixed them.

Mini Project / Challenge

Create a small Python exercise that combines at least three ideas from Functions. Start with a tiny working version, test it, then improve it one step at a time.

  1. Choose three topics from this chapter.
  2. Write or adapt a small Python example using those topics.
  3. Predict the output before running the code.
  4. Test at least one different input.
  5. Write two sentences explaining what the program does and what you learned.

20 Questions & Answers

1. What is the main goal of Chapter 17?

The goal is to understand functions through small explanations, examples, and practice.

2. Should I memorize every command or method?

No. Understand the pattern, practice the common form, and learn how to read documentation when you need exact details.

3. Why are the examples small?

Small examples isolate one idea at a time, which makes errors easier to understand and fix.

4. What should I do when an example gives an error?

Read the last part of the traceback, check spelling and indentation, confirm the required package or file exists, and compare the input types with what the operation expects.

5. Why should I predict output before running code?

Prediction forces you to reason about the program instead of only copying it.

6. What should I remember about Defining Functions?

Remember its beginner meaning, the problem it helps solve, the shape of a small example, and one common situation where it is appropriate.

7. What should I remember about Calling Functions?

Remember its beginner meaning, the problem it helps solve, the shape of a small example, and one common situation where it is appropriate.

8. What should I remember about Parameters?

Remember its beginner meaning, the problem it helps solve, the shape of a small example, and one common situation where it is appropriate.

9. What should I remember about Arguments?

Remember its beginner meaning, the problem it helps solve, the shape of a small example, and one common situation where it is appropriate.

10. What should I remember about Return Values?

Remember its beginner meaning, the problem it helps solve, the shape of a small example, and one common situation where it is appropriate.

11. What should I remember about Multiple Return Values?

Remember its beginner meaning, the problem it helps solve, the shape of a small example, and one common situation where it is appropriate.

12. What should I remember about Default Arguments?

Remember its beginner meaning, the problem it helps solve, the shape of a small example, and one common situation where it is appropriate.

13. What should I remember about Keyword Arguments?

Remember its beginner meaning, the problem it helps solve, the shape of a small example, and one common situation where it is appropriate.

14. What should I remember about Positional Arguments?

Remember its beginner meaning, the problem it helps solve, the shape of a small example, and one common situation where it is appropriate.

15. What should I remember about Arbitrary Arguments?

Remember its beginner meaning, the problem it helps solve, the shape of a small example, and one common situation where it is appropriate.

16. What should I remember about *args?

Remember its beginner meaning, the problem it helps solve, the shape of a small example, and one common situation where it is appropriate.

17. What should I remember about **kwargs?

Remember its beginner meaning, the problem it helps solve, the shape of a small example, and one common situation where it is appropriate.

18. What should I remember about Function Documentation?

Remember its beginner meaning, the problem it helps solve, the shape of a small example, and one common situation where it is appropriate.

19. What should I remember about Pure Functions?

Remember its beginner meaning, the problem it helps solve, the shape of a small example, and one common situation where it is appropriate.

20. What should I remember about Function Design?

Remember its beginner meaning, the problem it helps solve, the shape of a small example, and one common situation where it is appropriate.