Learn CODEHS with Real Code Examples
Updated Nov 26, 2025
Code Sample Descriptions
1
Hello World in CodeHS (Karel the Dog, JavaScript-based)
function start() {
say("Hello World");
}
A simple CodeHS program where Karel the Dog writes 'Hello World' using a say command.
2
Hello World in CodeHS (Python)
print("Hello World")
A Python-based CodeHS example printing 'Hello World'.
3
CodeHS Karel Move Example
function start() {
move();
move();
move();
}
Karel moves forward 3 steps.
4
CodeHS Python Variables Example
x = 5
name = "Alice"
print(x)
print(name)
Declares variables and prints them.
5
CodeHS Karel Turn Example
function start() {
turnLeft();
turnLeft();
move();
}
Karel turns left 2 times and moves forward.
6
CodeHS Python If Statement
num = 7
if num > 0:
print("Positive")
else:
print("Non-positive")
Checks if a number is positive.
7
CodeHS Karel Put Beeper
function start() {
putBeeper();
move();
putBeeper();
move();
putBeeper();
}
Karel places 3 beepers in a line.
8
CodeHS Python Loop Example
for i in range(1, 6):
print(i)
Print numbers from 1 to 5 using a loop.
9
CodeHS Karel Pick Beeper
function start() {
pickBeeper();
move();
pickBeeper();
}
Karel picks up 2 beepers in sequence.
10
CodeHS Python Function Example
def add(a, b):
return a + b
print(add(3, 4))
Defines a function to add two numbers and prints result.