Introducing 

Prezi AI.

Your new presentation assistant.

Refine, enhance, and tailor your content, source relevant images, and edit visuals quicker than ever before.

Loading…
Transcript

Python Lesson 9

Functions

What are Functions?

What is a function?

How to cook rice

Steps to Cooking Rice

Recipe

1. Scoop rice into cooker

2. Add water to rinse the rice

3. Repeat rinsing rice until water is clear

4. Turn on rice cooker and enjoy

Functions are just like Recipes!

Why do we use Functions?

Why functions?

  • Easy to reuse
  • Efficient
  • Less code needed

Creating Functions

4 things we need:

  • keyword "def"
  • Function name
  • Parentheses ()
  • Colon :

How do you create functions?

Let's try making a function!

Start off with def

def

Next, your Function Name

Name

Add Parentheses and Colon

():

Finally, add code

Code

You're Done!

What are function parameters?

Parameters

Parameters are values that we can input into the function so that the function can use them

How do we use Parameters?

Here's an example

Is it possible to use more than one parameter?

Discuss with a partner

Yes, it is possible!

Notice the comma

We can use numbers too!

Use return to Return Function Output

Thank You

Learn more about creating dynamic, engaging presentations with Prezi