Using Variables

Printing Variables within Sentences

cheese-1129908_960_720Printing just a variable value like Pikachu or Squirtle isn’t very helpful. Add sentences and cheesevariable string values together using a plus (this is called concatenation):


This will print:


Remember to use speech marks for your printed statements but print the variable name to display the variable value:


This would print:


Printing Number Variables within Sentences

cookieIf you want to match together strings and number values then it is easiest to use a comma as a plus will not work:


This will output:



Variables not working? Tick off these common errors:

Consistent variable name?
Variable name only one word?
Don't use speech marks to print the variable
Does the variable have a value
Have you used a comma between different sections?

< Back to Section One