Explore what CodeHS has to offer for districts, schools, and teachers.
Click on one of our programs below to get started coding in the sandbox!
View All
What could you do to ensure the following program doesn’t result in an error?
cats = 2 dogs = 1 def animals(): parrots = 2 fish = 12 total = quads + parrots + fish print(total) animals()
Declare a global variable quads as cats + dogs
quads
cats + dogs
Declare fish and parrots as global variables
fish
parrots
Declare total a global variable
total
Call the animals() function before defining it
animals()