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 3: This or That
Boolean Variables and Conditionals
Boolean Variables
A boolean variable is a special type of variable that contains one of two possible values: true or false.
By themselves, boolean variables don't seem to do too much, but they are a powerful tool when working with control structures, as we will soon see.
Try it!
Make a boolean variable and assign it a value of true: boolean sayStatement = false.
Create a text variable named "greeting" and assign it a string you like in double quotes: text greeting = "Hello!"
We will use these variables in a couple slides.
Control Structures: If (Structure)
One powerful ability of a computer is to evaluate a condition and make a decision about which instructions to execute. These decisions can be made with a simple conditional statement, which in Quorum uses the keyword if.
An if statement has three parts: the keyword if followed by a condition, followed by the block of code to execute if the condition is true, followed by end.
boolean variables are often used to specify the condition.
Try it!
Create an if statement using the boolean from the last slide: if sayStatement = true and then type end on a new line and then move to the next slide.
Control Structures: If (Conditional Logic)
When determining whether to execute the block of code within the if statement the computer checks the condition part of the statement to see whether it is true or false.
You can specify the condition using a boolean variable or any other expression that evaluates to true or false
For example, if you typed if 1 + 1 = 4 the condition 1 + 1 = 4 evaluates to false, so the code is skipped.
If code is skipped, the computer jumps to the end keyword for the next instruction.
Try it!
Inside the previous if block type: say greeting and then Run your code.
Control Structures: If (elseif)
You can also specify an alternatve condition to evaluate if the condition in the first part of the if statement is false by using the keyword elseif before the end.
We can include as many elseif conditions as we want and include code blocks to execute in each case.
There is a single end statement at the conclusion.
Try it!
Continuing the example from the last slide, insert a new condition before the line end and then a line containing the code to execute: elseif sayStatement = false output greeting and then Run your code.
Control Structures: If (else)
There is one other optional part of an if statement called the default condition, which will execute if no other condition in the statement is true. In Quorum, this block is designated with the keyword else
In our example, there are only two states: true and false, so there are no other possible conditions, although the elseif line could be converted to an else without a second condition.
In other cases, you might have a list of conditions like: if x = 1 {code block} elseif x = 2 {code block} else {code block} end  (You can experiment or move on when ready)
If Statements: Additional Information
More documentation on if statements can be found here.
Try it Yourself
Next Tutorial
In the next tutorial, we will discuss Hour of Code Part 4, which describes first steps in Quorum.