Gallery
Variables with starter code
Share
Explore
Variables with starter code

icon picker
The Task

Activity: Variables 📄

Start Here

Run and explore the program.
Edit the values of the variables.
Try breaking the naming rules below, one at a time, then run the program to see what the error message says. Fix the program then break another rule.
every variable appears 2 times, so change the spelling once
insert a space into a variable name
insert a digit (0-9) at the start of a variable name
4.When you run the code you will see error messages. Read them and try to make out what they mean. Share your ideas with a partner or your teacher.
Have fun! 🙂

Naming Rules For Variables🆘

Key Points
consistency: name is not the same as Name or NAME.
spaces: variable names should not have a space in them. Try these instead:
snake_case with underscore: total_money
camelCase with uppercase/capitals: totalMoney
digits: variable names should not start with a digit
single purpose: You cannot use the same variable name for more than one purpose. For example suppose you used a variable called pokemon to store a pokemon’s name: pokemon = Pikachu then you also think of using the pokemon variable to store how many pokemon you have collected pokemon = 123. What will the pokemon actually store?
meaningful variable name: Use a name that describes to others what you are storing. For example if you are storing shoe size call it shoeSize or sizeOfShoe

Remember

You do not need to memorise any of the code!
Even the best programmers need to look up commands and the more you use the commands the more familiar they will become.
Everyone gets bugs!🐞
Even the most experienced programmers make mistakes. Try to fix one error at a time.
Share
 
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.