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.

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.

What You'll Learn in This Lesson

🔧 Before You Start: Do You Have Python?

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!

📁 Running Python on Your Computer

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.

1️⃣ What Is Python? (Plain English)

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.

🌍 Why Python? Real-World Proof

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.

2️⃣ What Is a Program?

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

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

🧠 How Python Executes Code: The Mental Model

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.

3️⃣ Your First Python Instruction: print()

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

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

4️⃣ Quotes (" " and ' ') — VERY IMPORTANT

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 " " .

5️⃣ Strings (What Text Is Called in Programming)

A string is any sequence of characters wrapped in quotes.

✂️ String Operations: Doing Things with Text

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.

6️⃣ Comments (#) — Leaving Notes in Your Code

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

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

7️⃣ Numbers (Not Text)

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

8️⃣ Variables (Storing Information)

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:

🔁 How Variables Actually Work

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.

9️⃣ Data Types: str, int, float, bool

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

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

⚡ Why Data Types Actually Matter

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.

🔟 Printing Multiple Values

You can print more than one thing at a time by separating values with commas:

Python automatically adds a space between them.

1️⃣1️⃣ Converting Types with str() — VERY IMPORTANT

When joining text and numbers with + , convert the number to text first using str() .

1️⃣2️⃣ f-Strings (The Modern, Easier Way)

Now that you understand strings and variables, let's learn a cleaner way to combine them.

f stands for formatted . An f-string lets you insert variables directly into text.

Without f-string (the old way we just learned):

1️⃣3️⃣ Arithmetic (Math Operations)

Python can perform calculations just like a calculator:

📐 Arithmetic Deep Dive: Things That Catch Beginners

Python follows standard maths rules. Multiplication and division happen before addition and subtraction:

Use parentheses whenever you want to control the order. When in doubt, add parentheses — they make your intent clear.

The / operator always returns a decimal (float), even if the result is a whole number. Use // when you need an integer result.

Modulo (%) — one of the most useful operators

% gives you the remainder after division. This sounds abstract until you see the pattern:

If number % 2 == 0 , the number is even. If it's 1, it's odd. You'll use this pattern constantly in future lessons.

1️⃣4️⃣ Getting Input From Users

int() converts the text input into a whole number.

Mini-Project: Personal Introduction Generator

You now know enough Python to write a real, useful program . This mini-project combines every concept from this lesson into one coherent script. This is the kind of thing you could show someone to prove you've learned programming.

Notice int(input(...)) — we convert immediately because we need to do maths with age.

Can you add a favourite_food variable and include it in the output? What about adding a school or job variable? The pattern is the same — just add more input() lines and use them in f-strings.

1️⃣5️⃣ Common Errors (Normal & Expected)

Errors happen to everyone — even professional programmers. Here's what the most common ones mean:

Why: You forgot the quotes around text. Python thinks hello is a variable that doesn't exist.

Why: You tried to join text and a number with + .

Why: Something is missing or mistyped — here, the closing parenthesis.

Fix: Check for missing quotes, parentheses, or colons.

Remember: Errors are feedback, not failure. They tell you exactly what to fix.

1️⃣6️⃣ Cheat Sheet (Lesson 1)

1️⃣7️⃣ What You Should Understand Now

Don't worry if some things aren't 100% clear yet. We'll practice more in the next lesson!

Great work — you've finished Lesson 1!

You now know what Python is, how to run a program, what print() does, and how strings, numbers, and comments work. You've already written your very first Python program — that's huge!

🚀 Up next: Variables & Data Types — learn how Python stores and remembers information so your programs can actually do things.

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".

Continue this course

Links on this page