Free Python guide

Python Guide for Beginners — Learn by Seeing

New to Python? Follow these free visual lessons in order. Each one animates the code so you see what Python is doing, not just what it prints.

Your learning path

  1. Python syntax explained
  2. Python for loop explained
  3. Python if / else explained
  4. Python while loop explained
  5. Python lists explained
  6. Python functions explained

Tips for learning Python fast

  • Predict the output before pressing Play, then check.
  • Change one value and visualize again to see what changes.
  • Type the examples yourself rather than only reading them.

Ready for more?

Sign up free for the full course — strings, dictionaries, sets, tuples and object-oriented programming — with quizzes and saved progress.

Practice exercises

Try each one yourself first, then open it in the Visualizer to watch every line run.

Exercise 1

Your first program

Ask nothing, just print a welcome message and the result of a calculation.

print("Welcome to Python!")
# print 12 times 4
Hint

* means multiply.

Show solution and explanation
print("Welcome to Python!")
print(12 * 4)  # 48

Python runs top to bottom, one line at a time. Watch the output panel fill in line by line.

Watch the solution step by step

Exercise 2

Simple calculator

Use input() to read two numbers and print their sum. Add 5 and 7 in the Visualizer's input box, one per line.

a = int(input("First number: "))
b = int(input("Second number: "))
# print the sum
Hint

input() gives text; int() turns it into a number.

Show solution and explanation
a = int(input("First number: "))
b = int(input("Second number: "))
print("Sum:", a + b)

Without int(), "5" + "7" would join the text into "57" instead of adding.

Watch the solution step by step

Exercise 3

Put it together

Use a loop, a condition and a list: print only the names that are longer than 3 letters.

names = ["Ali", "Fatima", "Zed", "Hamza"]
# loop + if + len()
Hint

len(name) gives the number of letters.

Show solution and explanation
names = ["Ali", "Fatima", "Zed", "Hamza"]
for name in names:
    if len(name) > 3:
        print(name)

This mixes three building blocks from the lessons above. The flow chart shows the TRUE and FALSE branches inside the loop.

Watch the solution step by step

Try your own code

Paste any code into the free visualizer, or sign up free for all visual lessons with quizzes and progress tracking.