Introduction

Python is a high-level, general-purpose programming language known for its clean, readable syntax and a huge ecosystem of libraries used for web development, data analysis, automation, and AI.

Learn Python, JavaScript, Java and more with free interactive lessons, real projects and AI-powered help. Beginner-friendly.

Part of the free Python course at LearnCodingFast — hands-on lessons with examples you run in your browser, plus practice exercises and a quick quiz.

Beginner-Safe, No Assumptions — Learn Python from absolute zero. Every concept is explained before it's used.

Many computers already have Python installed. Let's check if yours does.

Open Command Prompt (search "cmd" in Start menu) and type:

If you see something like "Python 3.x.x" — you're ready!

Let's create and run your very first Python program. Follow these steps exactly:

Open any text editor (Notepad on Windows, TextEdit on Mac, or any code editor). Create a new file and name it exactly:

The .py tells your computer "this is a Python file".

Type (or copy) this single line into your file:

Save it somewhere you can find it easily (like your Desktop or Documents folder).

Use the cd command to go to where you saved your file:

(Replace "Desktop" with wherever you saved the file)

If you see this, congratulations! You just ran your first Python program.

A programming language is a way for humans to give instructions to a computer. Think of it like learning a new language — but instead of talking to people, you're talking to machines.

Computers do nothing by themselves. They only follow instructions exactly as written. Your job is to write those instructions clearly.

Python is designed so that:

Python is used for:

But before building anything, we must learn the core basics. Let's start.

Python isn't just popular in classrooms — it powers some of the biggest products on the planet:

It's designed to be human-readable. Look at this comparison — both programs do the exact same thing:

Python's creator, Guido van Rossum, designed it to look like pseudocode.

That means you can often guess what Python code does before you've been taught it — which makes learning dramatically faster.

By Lesson 5 of this course, you'll be writing Python scripts that automate real tasks on your own computer.

A program is simply a list of instructions that a computer follows.

In Python, this looks different — but the idea is the same:

Before you write your first real instruction, it helps to picture what actually happens when you run Python code:

Python reads your code the same way you read a book — left to right, top to bottom.

It never skips ahead and never goes backwards (unless you tell it to). This is called sequential execution .

Line 1 always runs before line 2. Line 2 always runs before line 3. There are no surprises.

print() tells Python: "Show this on the screen."

It's the most basic way to make Python display something to you.

This is one of the most important things to understand early:

Python must know what is text and what is code.

Text MUST be wrapped in quotes. Without quotes, Python gets confused.

If you want to show words or sentences, they MUST be inside quotes.

Pick one style and use it consistently. Most beginners use double quotes " " .

A string is any sequence of characters wrapped in quotes.

A string isn't just something you print — you can do things with it . Here are the four most useful operations for beginners:

len() counts every character — including spaces, numbers, and punctuation.

The * operator repeats a string a set number of times.

Python starts counting from zero , not one. So word[0] is the first character. This will make more sense as you progress — just plant that seed now.

Sometimes you want to write notes in your code that Python should ignore completely.

Anything after the # symbol is a comment — Python skips it.

They look similar — but Python treats them completely differently. This matters when you start doing calculations.

A variable is like a labeled box that stores a value.

You give the box a name, and put something inside it.

Read this as: "Create a box called age and put the number 16 inside it."

Variables can store different types of values:

Two things about variables that confuse almost every beginner — let's clear them up now.

A variable isn't locked to its first value. You can change it as many times as you like:

The old value (16) is simply overwritten. Python only remembers the most recent value.

In Python, = means "store this value" . It does not mean "these two things are equal".

For equality checks, Python uses == (double equals). You'll learn about this in the next lesson. For now, just remember: one = stores, two == compares.

Python organizes data into different types . Here are the four most common:

Only two possible values: True or False (note the capital letters)

Data types aren't just labels — they change how Python behaves with your data. The same symbol can do completely different things depending on the type:

String + string = concatenation (joined together)

This is why types matter. Python does different things with the same symbol based on the type of data you give it. Understanding this saves you from hours of debugging confusion.

The type() function — ask Python "what type is this?"

If you're ever unsure what type a value or variable is, just ask Python directly:

type() is one of Python's most useful debugging tools. When something isn't working as expected, checking the type often reveals the problem immediately.

Practice quiz

What does print("Hello, World!") do?

  • Creates a variable called Hello
  • Saves text to a file
  • Shows the text Hello, World! on the screen
  • Causes a NameError

Answer: Shows the text Hello, World! on the screen. print() displays whatever is inside the parentheses on the screen.

Why does print(Hello) (without quotes) fail?

  • Python treats Hello as a variable that does not exist, raising a NameError
  • Python ignores it
  • It prints an empty line
  • It prints the word Hello

Answer: Python treats Hello as a variable that does not exist, raising a NameError. Without quotes Python thinks Hello is a variable name; since none exists, it raises a NameError.

What is the value 16 in age = 16?

  • A string
  • A float
  • A boolean
  • An integer (int)

Answer: An integer (int). Whole numbers written without quotes or decimals are integers (int).

What does print("5" + "3") output?

  • 8
  • 53
  • An error
  • 5 3

Answer: 53. Both are strings, so + concatenates them into "53".

What does print(2 + 3 * 4) output?

  • 14
  • 20
  • 24
  • 9

Answer: 14. Multiplication happens before addition: 3 * 4 = 12, then 2 + 12 = 14.

In Python 3, what does print(10 / 2) output?

  • 5
  • 2
  • 5.0
  • An integer

Answer: 5.0. The / operator always returns a float in Python 3, so the result is 5.0.

What type does input() always return?

  • An integer
  • A string
  • A float
  • Whatever type the user typed

Answer: A string. input() always returns a string, even if the user types a number.

Which f-string correctly inserts the variable age?

  • "I am {age}"
  • f"I am age"
  • "I am " age
  • f"I am {age}"

Answer: f"I am {age}". An f-string needs an f before the quote and the variable inside curly braces.

What does len("Hi there") return?

  • 7
  • 8
  • 2
  • 6

Answer: 8. len() counts every character including the space, so "Hi there" is 8 characters.

What does "Python"[0] evaluate to?

  • "y"
  • "Python"
  • "P"
  • An error

Answer: "P". Python indexes from zero, so position 0 is the first character, "P".