Skip to Content
Learn
Variables
Changing the Value of a Variable

The strong selling point of using a variable is that we can easily change their value, making our programs flexible.

As we saw in the last exercise, we can save a number to a variable and reuse it throughout a program:

my_number = 847595593392818109495 my_number * 2 my_number / 4

We could easily switch out the value of my_number, without having to change that number in multiple places in our code.

my_number = 1 my_number * 2 my_number / 4

We could also change the value of my_number part way through our program:

my_number = 1 my_number * 2 my_number = 3 my_number / 4

Instructions

You’d like there to be options for an expansion pack, and that means — more terrains!

Use the drop-down menus to explore the different options for the board and try creating new game designs by swapping out the different terrains.

Folder Icon

Take this course for free

Already have an account?