Skip to content
Laviyx Learn

Try

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.

Beginner6 min readUpdated
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:

Python
print("Hello, world!")
Output
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, and not.
  • 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?#

AreaExamples
AutomationRename hundreds of files, fill spreadsheets, send reports
Data analysisClean data, calculate statistics, draw charts
Web developmentBack-end servers with frameworks like Django and Flask
AI and machine learningTrain models with libraries like PyTorch and scikit-learn
Scripting and toolsCommand-line tools, bots, small utilities

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.

Python
print("First")
print("Second")
print("Third")
Output
First
Second
Third

Because 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:

Python
name = "Asha"
age = 21

print("Hello,", name)
print("Next year you will be", age + 1)
Output
Hello, Asha
Next year you will be 22
  • name = "Asha" stores the text "Asha" under the name name. This is a variable.
  • age + 1 is calculated before it is printed.
  • print can 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.

Python
age = 20
if age >= 18:
    print("You can vote")
print("This line always runs")
Output
You can vote
This line always runs

The 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:

Python
# Calculate the total price
price = 250
quantity = 3
print(price * quantity)  # 750

Common mistakes#

Practice#

Practice exercise

Predict the output of this program before you check the solution:

Python
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
Output
Learning
Python is fun
15
10 + 5

10 + 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?