PYTHON CORE · LESSON 09

Functions

A command named · about 12 minutes

Learning with progressRead the summary for free. To save the work, log in to the account.
STEP 1

Create your own command.

A function is a set of actions with a name. The word def creates a function. After the name, you need brackets and colons.

def wave():
    print("Привет!")

✦ So far, the function has only been created and has not output anything.

STEP 2

Call the function.

To work, write the name of the function with brackets. It's a function call.

def wave():
    print("Привет!")
wave()

✦ Now it's going to be Hello!

IN-CLASS PRACTICE

Type the code yourself

Set an example. First the function is created, then called.

def hello():
    print("Здравствуй!")
hello()
Open the editor for class work
HOMEWORK

Solve it yourself

Create a cheer function that outputs «Ура!». Then call cheer.

The answer is hidden. Use similar examples from the lesson notes.

Opening up your homework