Your learning path
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 4Hint
* means multiply.
Show solution and explanation
print("Welcome to Python!")
print(12 * 4) # 48Python runs top to bottom, one line at a time. Watch the output panel fill in line by line.
Watch the solution step by stepExercise 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 sumHint
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 stepExercise 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