top of page

A Big Calculator

Other Operations

Comments

Checkpoint #1

Variables

Checkpoint #2

Summary

Variables

In programming, variables are placeholders for information you would like to store and use later. Variables are very common in algebra; for example, if we use x as a variable to store the value 3 (x = 3), then later we can recall this value 3 simply by recalling the variable x.

 

We can also use variables to perform calculations. For example, 2 * x will return the value 6.

 

Finally, we can replace the value of a variable. That is, if we set x = 4, then the same calculation, 2 * x will return the value 8

Let's give it a try in code:

1 # Create a variable, x, with the value 3

2 x = 3

3 print("x = ", x)

4 print("2 * x = ", 2 * x)

bottom of page