Beginning of dialog window. It congratulates you on completing this exercise. Escape will cancel an close the window.
Congratulations, you've completed this exercise!
Would you like to...
You can always navigate to any page at a later time.
Beginning of dialog window. It asks that code be input before running.
There isn't any code
Type in some code and then press the run button to see what it does
Part 1: Got a New Gig
Learn About Variables
Variables
In programming, a variable is a container to store information that can be used at a later time.
In Quorum, there are four types of basic variables: text, number, integer and boolean. Each type of variable holds a different kind of information.
In this first example, we will create a text variable, which holds a text string of anything you want to type in. We'll explain the other types in the next sections.
Notice that a text string is enclosed in two double quotation marks.
Creating Variables
To create a variable in Quorum, we start by telling the computer what type of variable we want to make, in this case it's a text variable, followed by a space and a name for the variable.
The important thing to remember about naming a variable is that a variable needs to start with a letter. After that, you can have numbers or more letters in the name.
Storing Text in Variables: Literals
Now we have made a variable named dna, but we haven't stored any information in it yet, so it's empty.
To store a value into a variable we use the = operator, followed by the information we want stored.
For this example, let's store the text string "GATTACA" in our dna variable.
Remember to put double quotes around the string we're storing in a text variable to tell the computer we want to store exactly what we typed.
Try it!
Store the text "GATTACA" to the dna variable: text dna = "GATTACA" then go to the next slide.
Using Variables for Output
Now that we've stored something in our variable, we can refer to its contents whenever we need to by using the variable name.
To demonstrate this, let's take what we have stored in our variable and display it to the screen.
In Quorum, to output information to the screen we type the word output followed by a space and then whatever we want to show up on screen.
Try it!
Output the contents of the dna variable by typing output dna on a new second line and hit the green Run button to see the output.
Storing Text in Variables: From Variables
If we want to assign the value of one variable to another variable, we can use the = operator to copy the contents.
We can also use the + operator to put more than one thing into a variable.
For text variables putting two strings into the same variable puts them one after the other.
Try it!
Create a new variable called text msg and then use the = operator to put the string and variable "Welcome to " + dna into it. On the next line, output the msg variable: output msg.
Additional Information Regarding Variables
Names are case sensitive: dna is not the same as DNA.
When storing a string into a text variable, be sure to use double quotes.
Because variables are just containers, if we change what is stored inside of it we can still use the same output statement and get a different result on screen.
If you've been following along, you can test this by changing what is initally stored in the dna variable.
Try it Yourself
Next Tutorial
In the next tutorial, we will discuss Hour of Code Part 2, which describes first steps in Quorum.