PYTHON CORE · LESSON 11

Introduction of text

The program asks a question. · about 11 minutes

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

Ask the man.

input displays a question and waits for an answer. The answer can be saved to a variable.

name = input("Как тебя зовут? ")

✦ If you write Leo, the text in name is Leo.

STEP 2

The answer changes the program

Now the program can say something to this person. input always returns text.

name = input("Как тебя зовут? ")
print("Привет, " + name)

✦ Enter Leo, you'll see Hello, Leo.

IN-CLASS PRACTICE

Type the code yourself

Reprint the example. The question should be inside input.

city = input("Твой город? ")
print("Город: " + city)
Open the editor for class work
HOMEWORK

Solve it yourself

Ask your favorite color and save the answer in color. Output «Твой цвет: » and answer. You can think of the question yourself.

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

Opening up your homework