🧩 Programming
Programming Lab
Explore logic, experiment with code, and solve problems step by step.
Your progress
Sign up free to save your programs, track your progress and earn badges.
Sign up freeContinue learning
Choose a topic below to start. No programming experience needed.
Beginner topics
Programming basics · 1
Decision making · 4
-
Can we play outside? AND, OR and NOT
NOT turns true into false; AND is true only when both parts are true; OR is true when at least one part is true, so a long condition can be worked out one part at a time
Beginner About 12 min Premium New -
If it rains, take an umbrella
An if / else statement checks a condition: when it is true the program runs the then part, otherwise the else part, never both
Beginner About 12 min Free New -
Is it a leap year?
A year is a leap year when it divides by 4 and not by 100, or when it divides by 400; the remainder % tests divisibility and AND / OR join the rules into one condition
Beginner About 12 min Premium New -
Three tries for a PIN
A loop condition joined with AND stops as soon as either part is false: here when the PIN is right or when three tries are used up
Beginner About 12 min Premium New
Loops and patterns · 4
-
Adding the digits of a number
n % 10 is the last digit of n and floor(n / 10) is n without it, so a while loop that repeats both until n is 0 visits every digit once
Beginner About 12 min Premium New -
FizzBuzz: loops, % and decisions
A loop can make a decision on every repeat: i % 3 == 0 is true when 3 divides i exactly, and in a chain of ELSE IFs the first true check wins, so the most special case must come first
Beginner About 15 min Premium New -
Repeat with a loop
A loop repeats the same lines: a for loop runs once for each value of its counter, an accumulator adds something on every repeat, and a while loop repeats until its condition becomes false
Beginner About 15 min Premium New -
Saving up with a while loop
A while loop repeats its body as long as its condition is true, so the body must change something that makes the condition false in the end, or the loop never stops
Beginner About 12 min Premium New
Data structures · 1
Algorithms · 1
Functions and recursion · 1
Computational thinking · 2
-
A traffic light is a state machine
A state machine is always in one of a few states and moves to the next state by a rule; a traffic light keeps its state in a variable and goes round red, green, yellow with (state + 1) % 3
Beginner About 12 min Premium New -
Help the robot reach the battery
An algorithm is a list of exact steps done in order; changing the order or one step changes the result, and debugging means finding the step where the plan breaks
Beginner About 12 min Free New