Conditionals and Loops

“I taught myself how to program computers when I was a kid, bought my first computer when I was 10, and sold my first commercial program when I was 12.” - Elon Musk


When computers run a program they need to follow commands. A command that uses a conditional statement uses the word “if”. In a Loop, a code block is followed until some condition is met. When a computer sees these codes, it follows the commands if they are true and stops when they are false. For example, when you are playing a game, and the player jumps when you hit the spacebar, that is a conditional: - if(player.pressSpacebar), then { player.jump(); }.


Play a game like Simon Says with a friend or family member. They are your Computers and you are the Programmer. Make it complex by using Conditionals or Loops. You could say, “If I raise my left hand, you raise your right hand” (a conditional) or “While I am jumping, you are clapping.” ( a Loop) Then try to build onto that with more statements and see how many you all can remember. Try starting with five statements for one game and then add on more.


This program has been designed for you to share with your child. Read the material together, ask questions and encourage your child to ask questions. Then nurture their curious mind by doing the activities with them. Books included are available via CPL’s digital library (with a library card).