Incrementing Ints
In computer programming, you often need to increase a variable by one.
Dependencies
Students need to have these skills before learning this skill:
Goal
When you teach this skill, your goal is to make it so that students can write code that looks like this:
score = 0
score = score + 1
Activities
Here are some activities that you can do in order to teach this skill.
Writing on the board
-
Write this code on the board:
score = 0
print(score)
score = score + 1
print(score) -
Ask students what they think that code is going to do.
-
After calling on a few students, reveal the correct answer.
-
Ask all students to write similar code on their computers. Students can choose a different variable name when copying the code if they want to.
-
Have students run their code in order to make sure that it works.