Cloud Explainers

Every Python Concept for Beginners in 10 Minutes

Python9 min videoPublished Nov 8, 2026

Every Python concept a beginner needs, run for real in Python 3.15 on a tiny tea shop: variables and types, strings and f-strings, lists, dictionaries, if and else, loops, functions and errors. We start from a real first error (TypeError: can only concatenate str), learn to read it from the bottom up, catch the print-versus-return trap, and finish by reading every line of a 23-line receipt program that uses all eight.

Every Python Concept for Beginners in 10 Minutes, the full picture: diagram of Variables, Strings, Lists, Dictionaries, If and else, Loops, Functions, Errors, Data: what the program remembers, Logic: what the program does
The whole picture, from the video's recap.

Your first error

Your first Python program crashed, and the error makes no sense. Ana runs a small tea shop, and this is her first program: store two tins, then print them. Python stops with a wall of text, and a type error at the bottom.

Ana's laptop
cat order.pytins = 2
print("Tins: " + tins)
Ana's laptop
python3 order.pyTraceback (most recent call last):
  File "/home/ana/shop/order.py", line 2, in <module>
    print("Tins: " + tins)
          ~~~~~~~~~^~~~~~
TypeError: can only concatenate str (not "int") to str

Nothing here is hard. Almost every beginner program is built from the same eight ideas, and this error is two of them bumping into each other. By the end, you'll read that error at a glance, and every line of Ana's finished receipt program. One of the eight hides a trap that catches almost everyone: a function that prints the right answer, yet gives back nothing. We'll see why.

That trap is so common, one Stack Overflow question about it, what is the return statement for, and how is it different from printing, has been viewed over 710 thousand times since 2011.

One beginner question: figure of 712,421 views: what's the difference between return and print?, source: Stack Overflow, asked 2011

Variables and types

How does a program remember anything? With variables: names that point at values. Every command and file here is linked in the description, to run yourself.

tins equals two doesn't say tins is two. The equals sign means: make the name tins point at the value two. And every value has a type. Two is an int, a whole number. Six point five is a float, a number with a decimal point. Text in quotes is a str, short for string.

Names point at values, and values have types: diagram of tins, 2, price, 6.5, name, "Ana", names, values

Here it is in Python's own prompt, the three arrows: each line runs when you press Enter. tins plus one gives three. type of tins says int, the quoted two is a str, and six point five is a float.

Python 3.15 on Ana's laptop
python3Python 3.15.2 (main, Nov  5 2026, 08:02:30) [GCC 14.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
Python 3.15 on Ana's laptop
>>> tins = 2
Python 3.15 on Ana's laptop
>>> tins + 13
Python 3.15 on Ana's laptop
>>> type(tins)<class 'int'>
Python 3.15 on Ana's laptop
>>> type("2")<class 'str'>
Python 3.15 on Ana's laptop
>>> type(6.5)<class 'float'>

Types decide what plus means. Two strings are glued together: two two, in quotes. Add two ints, and you get four. So Ana's error says: you can't glue text to a number. Turn the number into text with str first, and it works.

The type decides what + means: comparison table of You type vs Python 3.15 answers

Types matter at any size. At Dropbox, Python is the most widely used language, and its engineers added type labels to almost four million lines of it, so a checker can catch mistakes like Ana's before the code even runs.

Types at Dropbox: figure of 4 million lines of Python with type labels, source: Dropbox engineering blog

Strings

How do you build a sentence out of names and numbers? With strings, and one small letter: f.

A string is text between quotes. Put an f in front, and anything in curly braces is filled in with a variable's value. name becomes Ana, tins becomes two, and Python turns the number into text for you: the fix for Ana's error, with less typing.

An f-string fills in the braces: diagram of f"{name} ordered {tins} tins", f = f: fill in, {name} = becomes Ana, {tins} = becomes 2, No str needed: the f-string does it

For real: Ana ordered two tins. Strings also come with tools. Dot upper gives capitals, and len counts the characters: Sencha has six.

Python 3.15 on Ana's laptop
>>> name = "Ana"
Python 3.15 on Ana's laptop
>>> f"{name} ordered {tins} tins"'Ana ordered 2 tins'
Python 3.15 on Ana's laptop
>>> name.upper()'ANA'
Python 3.15 on Ana's laptop
>>> len("Sencha")6

Lists

What if the shop sells more than one tea? A list keeps many values, in order.

A list goes in square brackets, with commas between the items. Each item has a position number, its index, and Python counts from zero: Sencha is zero, Assam is one, Oolong is two. Minus one counts back from the end.

teas = ["Sencha", "Assam", "Oolong"]: diagram of Sencha, Assam, Oolong, the list teas

Index zero is Sencha, one is Assam, and minus one gives Oolong, the last. Append adds Earl Grey to the end, and len now says four. Four items. So what's at index four? Not Earl Grey. It's an index error. Four items means indexes zero to three.

Python 3.15 on Ana's laptop
>>> teas = ["Sencha", "Assam", "Oolong"]
Python 3.15 on Ana's laptop
>>> teas[0]'Sencha'
Python 3.15 on Ana's laptop
>>> teas[1]'Assam'
Python 3.15 on Ana's laptop
>>> teas[-1]'Oolong'
Python 3.15 on Ana's laptop
>>> teas.append("Earl Grey")
Python 3.15 on Ana's laptop
>>> len(teas)4
Python 3.15 on Ana's laptop
>>> teas[4]Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
    teas[4]
    ~~~~^^^
IndexError: list index out of range

Dictionaries

How does Ana find one tea's price without counting positions? With a dictionary: values you look up by a key.

A dictionary goes in curly braces: a key, a colon, then its value. Sencha costs six point five; Assam costs four. Ask for a key in square brackets, and you get its value. Assign to a new key, and it's added: Oolong, eight.

A dictionary: each key points at its value: diagram of "Sencha", 6.5, "Assam", 4.0, "Oolong", 8.0, the dictionary prices

The price of Assam: four point oh. After adding Oolong, there are three teas. Now ask for Matcha, which Ana doesn't sell, and Python raises a key error. Dot get asks politely instead: when the key is missing, you get the default you chose, zero.

Python 3.15 on Ana's laptop
>>> prices = {"Sencha": 6.5, "Assam": 4.0}
Python 3.15 on Ana's laptop
>>> prices["Assam"]4.0
Python 3.15 on Ana's laptop
>>> prices["Oolong"] = 8.0
Python 3.15 on Ana's laptop
>>> prices{'Sencha': 6.5, 'Assam': 4.0, 'Oolong': 8.0}
Python 3.15 on Ana's laptop
>>> prices["Matcha"]Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
    prices["Matcha"]
    ~~~~~~^^^^^^^^^^
KeyError: 'Matcha'
Python 3.15 on Ana's laptop
>>> prices.get("Matcha", 0)0

If and else

So far, every line runs. How does a program choose which lines run? With if, elif, and else.

Ana's shipping rule: twenty or more ships free, ten or more pays two, anything less pays three fifty. Python checks the conditions from the top, and runs only the first one that's true. For a fourteen order, the first check is false, and the second is true.

total = 14.0: diagram of total >= 20?, Free shipping, total >= 10?, Shipping: 2.00, anything else, Shipping: 3.50

In code, each condition ends with a colon, and the lines that belong to it are indented, usually by four spaces: the indent is how Python knows what's inside. One equals sign stores a value; two equals signs compare.

shipping.py: cards of Each condition ends with a colon, Indented four spaces: inside the if, One = stores a value, Two == compare

Run it, and it prints shipping two. Now mix up the signs and write one equals in the if. Python stops before running anything, and even suggests the fix: maybe you meant two equals signs.

Ana's laptop
python3 shipping.pyShipping: 2.00
Ana's laptop
python3 typo.py  File "/home/ana/shop/typo.py", line 2
    if total = 20:
       ^^^^^^^^^^
SyntaxError: invalid syntax. Maybe you meant '==' or ':=' instead of '='?

Loops

How do you do the same thing for every tea, without copying the line? With a loop.

For tea in teas takes the list one item at a time. First, tea is Sencha, and the indented line runs. Then tea is Assam, and it runs again. Then Oolong. When the list runs out, the loop ends.

for tea in teas:: diagram of Sencha, Assam, Oolong, print("Pack the", tea), teas

Here's that loop in a file, and under it a second one, over range three. Range makes numbers to loop over. What do you think range three prints? Zero, one, two.

teas.py: cards of For each tea in the list, For each number in range(3)

Run it: pack the Sencha, the Assam, the Oolong, one line per tea. Then zero, one, two: three numbers, starting at zero like list indexes. The end number itself is never included.

Ana's laptop
python3 teas.pyPack the Sencha
Pack the Assam
Pack the Oolong
0
1
2

Functions

How do you reuse steps, without writing them twice? With a function. And this is where that trap is hiding.

def gives a name to some indented steps. Line total takes a price and a number of tins, and prints price times tins. Run it: thirteen point oh appears, so it looks right. But cost is None, Python's word for nothing.

Ana's laptop
cat line_total.pydef line_total(price, tins):
    print(price * tins)

cost = line_total(6.5, 2)
print("Cost:", cost)
Ana's laptop
python3 line_total.py13.0
Cost: None

Here's why. Print shows a value on the screen, for a person to read. The code that called the function gets nothing back. Return hands the value back to the caller. Python's own tutorial says it: a function without return still gives back a value, None.

print shows it, return hands it back: diagram of Your code, line_total, Screen, line_total(6.5, 2), print: 13.0, None, return: 13.0, Print is for people. Return is for your code.

Change print to return, and cost is thirteen point oh: a value the rest of the program can use. That's the answer to the Stack Overflow question: print is for people, return is for your code.

Ana's laptop
cat line_total_fixed.pydef line_total(price, tins):
    return price * tins

cost = line_total(6.5, 2)
print("Cost:", cost)
Ana's laptop
python3 line_total_fixed.pyCost: 13.0

Errors

And when the program crashes anyway? Read the error, then handle it.

Back to Ana's first error. A traceback reads from the bottom up. The last line says what went wrong: a type error, gluing a str to an int. Above it, the code that failed, and above that, the file and the line number: order dot py, line two.

Read a traceback from the bottom up: diagram of Traceback, File, line 2, The code, TypeError

Some errors aren't mistakes in the code: a person types the word two, where a number belongs. int can't turn that into a number, so it raises a value error, and the program stops.

Ana's laptop
python3 ask.pyHow many tins? two
Traceback (most recent call last):
  File "/home/ana/shop/ask.py", line 1, in <module>
    tins = int(input("How many tins? "))
ValueError: invalid literal for int() with base 10: 'two'

Try runs the risky lines. If a value error happens, Python jumps to except instead of crashing, and Ana's program asks politely for a number.

ask_safe.py: cards of try: the risky lines, except: what to do instead

Same input, the word two. No traceback this time: please type a number.

Ana's laptop
python3 ask_safe.pyHow many tins? two
Please type a number, like 2

All eight together

Here's Ana's receipt program, 23 lines, and you can now read every one. A dictionary of prices, a function that returns a line's cost, try and except around the input, a loop over a list of teas, an f-string for each line, and an if for shipping.

Ana's laptop
cat receipt.pyprices = {"Sencha": 6.5, "Assam": 4.0}

def line_total(tea, tins):
    return prices[tea] * tins

try:
    tins = int(input("Tins of each tea: "))
except ValueError:
    print("Not a number, so 1 tin each")
    tins = 1

total = 0
for tea in ["Sencha", "Assam"]:
    cost = line_total(tea, tins)
    print(f"{tea}: {cost:.2f}")
    total = total + cost

if total >= 20:
    print("Free shipping")
else:
    total = total + 3.5
    print("Shipping: 3.50")
print(f"Total: {total:.2f}")

Two tins of each: twenty-one, with free shipping. And type the word two: no crash, one tin each, and fourteen with shipping.

Ana's laptop
python3 receipt.pyTins of each tea: 2
Sencha: 13.00
Assam: 8.00
Free shipping
Total: 21.00
Ana's laptop
python3 receipt.pyTins of each tea: two
Not a number, so 1 tin each
Sencha: 6.50
Assam: 4.00
Shipping: 3.50
Total: 14.00

Recap

Eight ideas. Variables, strings, lists and dictionaries hold the data. If, loops and functions decide what runs. And errors tell you exactly where to look.

Every command and the lab files are in the description, to try yourself. If this made your first error less scary, a like helps YouTube show it to other new programmers, and subscribing helps a small channel reach more beginners.

Everything here ran for real on Python 3.15.2. Thanks for watching Cloud Explainers.

Sources

Demos: one Python container on our own Mac; the tea shop and its customers are made up. Watch the full video on YouTube.

More videos

Linux9 min

Linux Makefiles Will Finally Make Sense After This

Auth (OAuth, JWT)9 min

SAML vs OAuth vs OpenID Connect: What's the Difference?

Python7 min

How to Fix Python cron Jobs That Never Run

Linux22 min

Linux Bash Scripting: Full Tutorial for Beginners

Networking10 min

How PXE Network Boot Works

Active Directory9 min

How Active Directory Works

Linux10 min

How to Fix a Linux systemd Service That Won't Start

Linux9 min

Linux Logs: syslog vs journald

Auth (OAuth, JWT)9 min

JWT vs Session Cookies: Which One Should You Use?

Docker10 min

Docker vs Docker Compose: Which One Should You Use?

Docker9 min

How to Fix Docker Compose Containers That Can't Talk to Each Other

Django (Python web framework)22 min

Django Full Tutorial for Beginners

Linux9 min

How Linux systemd Works

Networking8 min

How to Fix 'Windows Cannot Access' Network Share Errors (SMB)

APIs10 min

REST vs gRPC: Which One Should You Use?

Certificates & PKI (ADCS)9 min

How to Fix SSL Certificate Chain Errors (Missing Intermediate)

Databases & SQL9 min

Every SQL Join Type in 10 Minutes

OpenRouter (one API for many AI models)9 min

Why OpenRouter Free Models Hit Their Limit So Fast

Gemini API & Google AI Studio9 min

Why Your Gemini API Free Tier Runs Out So Fast

OpenRouter (one API for many AI models)10 min

OpenRouter Will Finally Make Sense After This

Caching & Redis10 min

How Redis Caching Works

Gemini API & Google AI Studio10 min

Gemini API vs Vertex AI: Which One Should You Use?

Gemini API & Google AI Studio8 min

How to Fix a Leaked Gemini API Key

Go (Golang)9 min

Why Golang Uses Goroutines Instead of Threads

Gemini API & Google AI Studio9 min

How to Fix Gemini API Error 429: Resource Exhausted

Claude & the Claude Developer Platform10 min

Claude Token Pricing Will Finally Make Sense After This

Python11 min

Why Python Web Scraping Returns Nothing (and the Fix)

Python10 min

Python uv vs pip: Which One Should You Use?

Python22 min

Python Automation: Full Tutorial for Beginners

Auth (OAuth, JWT)9 min

How OAuth Login Works

Gemini API & Google AI Studio10 min

Google AI Studio Will Finally Make Sense After This

Docker10 min

What Happens When You Run a Docker Container

Claude & the Claude Developer Platform8 min

How to Fix Claude Code Billing Your API Key Instead of Your Plan

Auth (OAuth, JWT)9 min

Why Passkeys Can't Be Phished Like Passwords

PowerShell10 min

PowerShell vs Bash: Which One Should You Learn?

Linux10 min

The Linux Roadmap for Beginners

Django (Python web framework)9 min

Django vs FastAPI: Which One Should You Use?

Databases & SQL10 min

Why SQLite Is the Most Used Database in the World

Databases & SQL11 min

How a NoSQL Database Like MongoDB Works

Python11 min

How to Fix Python pip error: externally-managed-environment

Databases & SQL9 min

How to Fix MySQL Too Many Connections Database Errors

Go (Golang)9 min

Golang Concurrency Will Finally Make Sense After This

AWS10 min

How Amazon S3 Works

Kubernetes10 min

How Kubernetes Works

Git10 min

How Git Works

Docker10 min

How to Fix Docker Port Already Allocated Errors

PostgreSQL10 min

How PostgreSQL Works

Git8 min

How to Fix Git Merge Conflicts

Linux9 min

How to Fix No Space Left on Device in Linux

Networking10 min

How the Internet Works

Databases & SQL9 min

SQL vs NoSQL: When Each One Wins

Auth (OAuth, JWT)8 min

How to Fix JWT Token Expired Errors (401 Unauthorized)

Claude & the Claude Developer Platform9 min

Claude API vs Claude Pro: Why Your Subscription Doesn't Include It

AI agent skills9 min

Why AI Agent Skills Beat Giant Prompts

Linux10 min

Linux Cron Jobs Will Finally Make Sense After This

Cybersecurity10 min

Security Logs Will Finally Make Sense After This

Cybersecurity8 min

How to Fix a Security Leak: An API Key Pushed to GitHub

DNS9 min

DNS Will Finally Make Sense After This

Cybersecurity9 min

Never Ignore a Security Update

Auth (OAuth, JWT)9 min

Two-Factor Authentication Will Finally Make Sense

Networking8 min

Never Expose a Database to the Internet

Cybersecurity10 min

SSH Keys vs Passwords: Which Is Safer for Security?

Linux10 min

The 5 Levels of Linux Boot: From Power On to Login

Networking12 min

The 5 Levels of Network Firewalls

Cybersecurity10 min

Password Security: Why Hackers Crack Weak Passwords

Linux9 min

Why Your Linux Server Runs Out of Memory

Networking10 min

HTTP vs HTTPS: What Actually Changes on Your Network

Linux12 min

Every Linux File Permission You Need to Know

Linux10 min

Linux Processes vs Threads: When Each One Wins

Networking11 min

The OSI Model Will Finally Make Sense After This

Git11 min

The 7 Levels of Git

Networking10 min

Every Network Troubleshooting Command You Need

Cybersecurity10 min

Hashing vs Encryption in Cybersecurity: When Each One Wins

Networking11 min

Why the Internet Ran Out of IP Addresses

Linux11 min

Linux Package Managers: apt vs Snap vs Flatpak

Python9 min

Why Python Is Slow (and When It Doesn't Matter)

Networking11 min

TCP vs UDP: When Each One Wins

Linux8 min

Stop Running Linux as Root (Do This Instead)

Linux11 min

Linux Users and Groups Will Finally Make Sense

Cybersecurity9 min

Why Phishing Beats Good Security (and How to Spot It)

Docker12 min

The 7 Levels of Docker

AI agents & MCP12 min

AI Agents Will Finally Make Sense After This

Git8 min

Stop Using git push --force (Use This Instead)

AI agent skills10 min

Agent Skills vs MCP: When Each One Wins

Networking12 min

Networking Will Finally Make Sense After This

Linux12 min

Every Linux Command You Actually Need

Cybersecurity12 min

The 7 Levels of Cybersecurity

System design12 min

Every System Design Concept You Need, in One Diagram

PostgreSQL10 min

Why PostgreSQL Ignores Your Index