> For the complete documentation index, see [llms.txt](https://docs.revrobotics.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.revrobotics.com/rev-professional-development-technical-path/blocks-boot-camp/variables/variables-practice.md).

# Variables Practice in Blocks

In Blocks, the Variable menu will first appear empty.&#x20;

<img src="https://3023198990-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnKoHwxC0Q1NBpLowZUmu%2Fuploads%2FH9626lvATXrbMZY6szTw%2Funknown.png?alt=media&amp;token=46aa9153-c97c-41bc-8ba3-b7c1a0937c61" alt="Default Variable menu" height="374" width="299">

Once variables are created, they will populate in the menu.&#x20;

<img src="https://3023198990-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnKoHwxC0Q1NBpLowZUmu%2Fuploads%2FZ7WArS8KjsTtXtzowyAc%2Funknown.png?alt=media&amp;token=7203ba12-7a45-4ace-a63a-28247af83725" alt="Variable menu with created variables" height="428" width="380">

HOWEVER, if a variable is not used when a program is saved then exited, it will be removed from the list again upon reopening the program. This is helpful for clearing unused or variables made by mistake, but may cause confusion for students of why something has been deleted.&#x20;

## Variable Activity

In a new OpMode, locate the telemetry blocks under Utilities. Add two for displaying numerical data to the OpMode's loop.

The keys will be set to "Answer 1" and "Answer 2" as seen below:

<img src="https://3023198990-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnKoHwxC0Q1NBpLowZUmu%2Fuploads%2FPbMD00yZLT8r6R2OBAHP%2Funknown.png?alt=media&amp;token=042e03c3-5414-4aa4-9930-e14b027f2e71" alt="Telemetry blocks added to the OpMode" height="458" width="443">

Create a variable called "A" and one called "B". Make "A" the number for the first telemetry and "B" for the second:

<img src="https://3023198990-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnKoHwxC0Q1NBpLowZUmu%2Fuploads%2FZ2MqH3xQ4LZAHfm726Ro%2Funknown.png?alt=media&amp;token=7af6ac84-3c14-4fac-a7f1-258cf95a531f" alt="Variables added to the telemetry" height="468" width="455">

Right now, our variables don't equal anything. Try saving your OpMode and seeing what happens when trying to run it.&#x20;

### Setting Variables

Let's start with using Constant Variables. We're set the variables during initialization so need to add the appropriate blocks here from the Variable menu:

<img src="https://3023198990-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnKoHwxC0Q1NBpLowZUmu%2Fuploads%2FJF56MkVPCbCcCGooiXdg%2Funknown.png?alt=media&amp;token=1ff20373-7ddb-4b11-9e14-e21a53226224" alt="Adding blocks to set the variables during initialization" height="508" width="451">

Now "A" and "B" can be set to a value using a number block from the Math menu. For this example, "A" is being set to 5 and "B" to 23:

<img src="https://3023198990-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnKoHwxC0Q1NBpLowZUmu%2Fuploads%2FH8ZFH24RdV3KRvLXD5VM%2Funknown.png?alt=media&amp;token=1111dd55-7b6a-4cd8-9795-84f01887361e" alt="Add a value to the variables" height="508" width="447">

What happens if you save and test the OpMode now?

### Adding Math

With our variables set, we can have the robot do some math for us to test out our variables!

Using the Math menu we can choose different equations to add to our telemetry:

![Example of math added to the telemetry blocks](https://3023198990-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnKoHwxC0Q1NBpLowZUmu%2Fuploads%2Fl5fkKaM7buCeb1FFdkzW%2Funknown.png?alt=media\&token=3f26ea3f-5913-47e9-9ee8-01d3c51ef765)

Save and test your OpMode!

<figure><img src="https://3023198990-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnKoHwxC0Q1NBpLowZUmu%2Fuploads%2FnmRBdNnaVkUSe1kvA33s%2FStop_Test.png?alt=media&amp;token=ba1415cd-d799-4a09-9dcb-8b3c3711e7b2" alt="" width="375"><figcaption></figcaption></figure>

Consider:&#x20;

* [ ] What happens if you change the equations?
* [ ] What happens if you change the value of the variables, but not the equation?
* [ ] What happens if the variable itself contains an equation?
