Python course menu
Introduction to Python: What It Is and Why Beginners Love It
A beginner-friendly introduction to Python. Learn what Python is, what people build with it, how Python code runs, and write and understand your first lines of code.
On this page
Python is a programming language: a way to give a computer precise instructions. It is famous for being easy to read, which makes it one of the best first languages to learn. It is also powerful enough to run parts of Instagram, Netflix's tooling, scientific research, and most of today's machine learning.
This lesson explains what Python is, what you can build with it, and how Python code actually runs. You do not need any experience.
What is a programming language?#
A computer only understands very low-level instructions. A programming language lets you write instructions in something closer to English, and a separate program translates them for the computer.
Here is a complete Python program:
print("Hello, world!")Hello, world!print is a built-in function: a named piece of code that does a job. Its job is to display whatever you put between the parentheses. The text inside the quotes is called a string.
Why learn Python?#
- Readable: Python code looks clean and uses plain words like
if,for,in, andnot. - Beginner-friendly: you can write useful programs with very little code.
- Versatile: the same language is used for websites, data analysis, automation, and AI.
- Huge community: almost every question you will have has already been asked and answered.
- In demand: Python consistently ranks among the most used languages by professional developers.
What can you build with Python?#
How Python runs your code#
Python is an interpreted language. That means a program called the Python interpreter reads your code and runs it line by line, from top to bottom.
print("First")
print("Second")
print("Third")First
Second
ThirdBecause it runs top to bottom, the order of your lines matters. This simple idea is the foundation of everything else in programming.
A slightly bigger example#
Do not worry about understanding every detail yet. Just read it:
name = "Asha"
age = 21
print("Hello,", name)
print("Next year you will be", age + 1)Hello, Asha
Next year you will be 22name = "Asha"stores the text"Asha"under the namename. This is a variable.age + 1is calculated before it is printed.printcan take several values separated by commas and puts a space between them.
You will learn variables properly in the Variables lesson.
Python's two big rules for beginners#
1. Indentation matters#
Many languages use curly braces to group lines. Python uses indentation: the spaces at the start of a line.
age = 20
if age >= 18:
print("You can vote")
print("This line always runs")You can vote
This line always runsThe indented line belongs to the if. The line that is not indented runs no matter what. The standard is four spaces per level.
2. Python is case-sensitive#
name, Name, and NAME are three different things to Python. Print("hi") fails because the function is called print, in lowercase.
Comments#
Anything after a # on a line is a comment. Python ignores it. Comments are notes for humans:
# Calculate the total price
price = 250
quantity = 3
print(price * quantity) # 750Common mistakes#
Practice#
Practice exercise
Predict the output of this program before you check the solution:
print("Learning")
print("Python", "is", "fun")
print(10 + 5)
print("10 + 5")Show hint
Python runs the lines in order. Look carefully at which values are inside quotes and which are not.
Show solution
Learning
Python is fun
15
10 + 510 + 5 without quotes is a calculation, so Python prints 15. "10 + 5" with quotes is just text, so Python prints it exactly as written.
Key takeaway#
Finished this lesson?