Your first program · Ваша первая программа
Welcome
- Python follows your instructions, one line at a time.
- You write code here and run it — nothing to install.
- Read each step, then press Continue.
Добро пожаловать
- Python следует вашим инструкциям, строка за строкой.
- Вы пишете код здесь и запускаете его — ничего устанавливать не нужно.
- Прочитайте каждый шаг, затем нажмите Продолжить.
Show text with print
print(...)shows text on the screen.- Put the text in quotes:
"...". - Each
printstarts a new line.
Вывод текста с помощью print
print(...)выводит текст на экран.- Поместите текст в кавычки:
"...". - Каждый вызов
printначинает новую строку.
print("Welcome to Python!")
print("This line runs next.")
Strings
- Text in quotes is called a string.
- You can use double quotes
"..."or single quotes'...'. - You can also print a number with no quotes, like
print(42).
Строки
- Текст в кавычках называется строкой.
- Можно использовать двойные кавычки
"..."или одинарные'...'. - Можно также вывести число без кавычек, например,
print(42).
Comments
- A line that starts with
#is a comment. - Python ignores comments — they do not run.
- Use them to leave notes for people who read your code.
Комментарии
- Строка, начинающаяся со знака
#, является комментарием. - Python игнорирует комментарии — они не выполняются.
- Используйте их, чтобы оставлять заметки для тех, кто читает ваш код.
# This line is a note for people. Python skips it.
print("Comments do not show.")
Common mistakes
printneeds quotes around text:print("Hi"), notprint(Hi).- Python is case-sensitive:
Printis not the same asprint.
Распространенные ошибки
- Для
printтекст должен быть в кавычках:print("Hi"), а неprint(Hi). - Python чувствителен к регистру:
Printиprint— это разные вещи.
Now you try
- Below are a few tasks. Type your code and press Run.
- Press Check answer to see if it is correct.
Теперь попробуйте сами
- Ниже приведено несколько заданий. Напишите код и нажмите Запустить.
- Нажмите Проверить ответ, чтобы узнать, верно ли оно.
How a program runs · Как работает программа
A program runs top to bottom, one statement at a time. · Программа выполняется сверху вниз, одна инструкция за раз.
Use print(...) to make Python show the words Hello, world! exactly (same spelling, same punctuation). · Используйте print(...), чтобы Python вывел слова Hello, world! точно (так же написаны, те же знаки препинания).
Click Run to see the output here. · Нажмите Запустить, чтобы увидеть результат здесь.
Print two lines. The first line must be My name is Pat. The second line must be I am learning Python. (Use two print(...) calls.) · Выведите две строки. Первая строка должна быть My name is Pat. Вторая строка должна быть I am learning Python. (Используйте два вызова print(...).)
Click Run to see the output here. · Нажмите Запустить, чтобы увидеть результат здесь.
Keep the comment line, then print the number 42. Notice the comment never appears in the output. · Оставьте строку комментария, затем print число 42. Заметьте, что комментарий никогда не появляется в выводе.
Click Run to see the output here. · Нажмите Запустить, чтобы увидеть результат здесь.
Print a box made of three lines: first +-----+, then | Hi! |, then +-----+ again. · Выведите рамку из трёх строк: сначала +-----+, затем | Hi! |, затем снова +-----+.
Click Run to see the output here. · Нажмите Запустить, чтобы увидеть результат здесь.