- Explain what a programming language and Python are
- Display text and numbers on the screen with print()
- Add comments to code and recognise simple errors
The apps on your phone, the videos YouTube suggests to you, the weather forecast — behind all of them are programs that tell a computer, step by step, what to do. People write these programs in special languages. In this lesson you will meet one of the most loved of them — Python — and write your very first program.
What is Python?
An artificial language with strict rules that people use to give instructions to a computer. Text written in such a language is called code.
Python is a simple, readable programming language. It was created by the Dutch programmer Guido van Rossum, and its first version came out in 1991. Because Python code looks a lot like plain English, it is considered one of the best languages to start with. At the same time, it is a powerful tool that professionals use every day.
- Websites and servers — big services such as Instagram use Python on their servers.
- Data analysis — tables, charts and statistics.
- Artificial intelligence — programs that recognise speech and images.
- Science — researchers process the results of experiments with Python.
- Automation — boring jobs such as renaming hundreds of files at once.
Your first program
Programmers have a tradition: when you learn a new language, your first program prints “Hello, world!” on the screen. In Python this takes just one line. Run the code and look at the result.
print('Hello, world!')▸ Expected output
Hello, world!
print is a ready-made Python function: it displays whatever you put inside its parentheses. Text inside quotation marks is called a string. In Python you can use single ('...') or double ("...") quotes — just make sure the opening and closing quotes match.
A program can have many lines. Python runs them from top to bottom, one at a time. If you give print several values separated by commas, it shows them on one line with spaces between them.
print('Hello! My name is Aysel.')
print('I live in Baku.')
print('I am', 12, 'years old.')
print('Year:', 2026)▸ Expected output
Hello! My name is Aysel. I live in Baku. I am 12 years old. Year: 2026
Python as a calculator
print can show not only text but also the results of calculations. Pay attention: '2 + 3' in quotes is just text, while 2 + 3 without quotes is an expression that Python calculates.
print(2 + 3)
print('2 + 3')
print(7 * 8)
print(100 / 4)
print('Total:', 45 + 30)▸ Expected output
5 2 + 3 56 25.0 Total: 75
Comments
Sometimes you want to leave a note in the code for yourself or for others. That is what comments are for: Python ignores everything from the # sign to the end of the line. Comments are also handy for temporarily “switching off” a line without deleting it.
# This program greets the learner
print('Welcome to Educora!') # greeting
# print('This line is switched off')
print('Python is fun!')▸ Expected output
Welcome to Educora! Python is fun!
Don't be afraid of errors
A computer does not guess what you meant — it follows your code to the letter. Even a small typo stops the program, and Python shows an error message. This is not a punishment but a hint: the message usually tells you exactly what went wrong.
| Code | Result | Why |
|---|---|---|
print('Hello') | Hello | Everything is correct. |
Print('Hello') | NameError | Python is case-sensitive: print is written in lowercase. |
print('Hello) | SyntaxError | The closing quote is missing. |
print(Hello) | NameError | There are no quotes, so Python looks for something named Hello and cannot find it. |
Make Python print two lines: Hello, Educora! on the first line and I am learning Python. on the second. Copy the text exactly, with the same punctuation.
# 1) print the text: Hello, Educora!
# 2) print the text: I am learning Python.▸ Expected output
Hello, Educora! I am learning Python.
A notebook costs 3 AZN and a pen costs 2 AZN. Aysel buys 4 notebooks and 5 pens. On the first line print Total: and the total cost; on the second line print Change: and the change from a 50 AZN note. Do not work out the numbers yourself — let Python calculate them.
# A notebook costs 3 AZN, a pen costs 2 AZN.
# Aysel buys 4 notebooks and 5 pens.
# 1) print Total: and the cost
# 2) print Change: and the change from 50 AZN▸ Expected output
Total: 22 Change: 28
Key points
- Python is a simple, readable and very widely used programming language.
print()displays the value in its parentheses; several values can be separated by commas.- Text in quotes is a string; an expression without quotes is calculated by Python.
- Python does not run comments that start with
#. - Python runs code from top to bottom and is case-sensitive.
Check yourself
10 questions. Every correct answer earns XP.
print('Hi') do?