Section 1 - Instruction

In our last course, we learned about loops to repeat actions. Maybe we could reuse entire chunks of code across different parts of our program.

Engagement Message

Have you ever wished you could copy-paste code but make it smarter?

Section 2 - Instruction

That's where functions come in! A function is like a mini-program inside your main program. You write the code once, give it a name, and then "call" it whenever you need it.

Think of it like having a helpful assistant.

Engagement Message

What would you name yours?

Section 3 - Instruction

Functions help us avoid writing the same code over and over. Instead of copying and pasting, we create a function once and use it multiple times. This makes our code cleaner and easier to fix.

Engagement Message

Can you think of any repetitive tasks in your daily life?

Section 4 - Instruction

Here's the basic structure of creating a function in Python. We start with def, then the function name, parentheses, and a colon. The function's code goes on the next lines, indented.

Engagement Message

Notice how similar this looks to if statements?

Section 5 - Instruction

Let's create our first function! This one will print a simple greeting:

Engagement Message

We've defined the function, but nothing happens yet. Why do you think that is?

Section 6 - Instruction
Sign up
Join the 1M+ learners on CodeSignal
Be a part of our community of 1M+ users who develop and demonstrate their skills on CodeSignal