In programming, a conditional (also known as "if-statement") is a control-flow statement directing your program to perform different actions depending on whether or not the programmer-specified condition is
For this example, we create a variable called Number and set it to the value 4.
Drag the "If" module from your Logic Panel as the next step in your program.
Your conditions are defined by using python syntax:
Number == 4 #Check if Number is Equal to 4Number != 4 #Check if Number is Not Equal to 4Number > 4 #Check if Number is greater than 4Number < 4 #Check if Number is less than 4Number >= 4 #Check if Number is greater than or equal to 4Number <= 4 #Check if Number is less than or equal to 4
In this example, let's check to see if our number is greater than 10. Our conditional statement would look like this within the editor:
We can also add additional branches to our conditional as Else-If branches. The first branch which is True will execute. If no branch is True then the Else branch will execute.
In this example, since our Number variable is equal to 4. We first check the if branch (furthest to the left) and that returns False since 4 is less than 10. We then check if Number is equal to 5. That also returns False. Therefore our else branch returns True.
We can now add different sets of actions to each branch of the conditional. If the condition is True, it will execute one set of actions, otherwise it will run a different set of actions. We can have as many branches as we want and the first branch that is True will execute (see note above).
Press the "Run Main" button to run your program. You can see that the If-statement evaluated to False (because 4 is not greater than 10 or equal to 5). Our program prints "Number is smaller than 10 and not 5!".
Try changing the number of your Number variable and rerunning the program.