Conditional Commands

Conditional Commands!!

Robots will execute the commands you give them IN THE ORDER THEY ARE RECEIVED!

Whatever you tell them to do first, they do first.

Whatever you tell them to do second, they do second.

And so on, and so on, and so on.....

UNLESS you interrupt the command flow. You can make your robot do different things based on the situtation.

Watch the video to the right for examples.

Now, let's have some fun with CONDITIONALS in a flow chart.

You are going to follow commands like a robot, but, intstead of following each command in order on-by-one, you are going to be using "conditionals". Before moving on to each "next step" you will need to decide if the condition described in the diamond shape is true or false.

You will need a piece of paper to write down some numbers.

For this activity, you need to think of a number larger than five, but smaller than 50.

Write it down! You are going to use this number to use the following flow chart.

Take NOTE!!

It doens't matter what number over five that you choose, you can eventually get to the number one using the same set of instructions.  Some numbers will take many more steps than others, but all will eventually get to the desired result with this one "program".  Because of that, you don't have to write a separate program for every number.

 You will first copy this flow chart to your paper on one side. 

Notice the shapes. Each diamond is a condition. 

Before moving to the next step after each diamond, you need to determine if the condition in the diamond is true or not.

That determines the direction of the path through the commands.

Note that the ACTUAL commands are in rectangles ( aside form the initial question at the top).

Now, it's your turn to create a flowchart. 

Let's make it fun. 

You need to choose a situation in which you would need to make a decision. 

Here are some examples:

Go see a comedy movie or a horror movie.

Eat Hot Takis or fresh fruit.

Stay home and do homework or go to mall with friends.

You can choose whatever you like, but you need to have at least three points in your flow chart where a yes/no decision is required.**

STEP 1: Begin the flow chart with the original decision to be made.

STEP 2: Make the second box a DIAMOND SHAPE with a yes/no question. This is your CONDITIONAL. If the condition is met (yes answer) then you follow the yes path. If the condition is not met (no answer), you follow the no path.

STEP 3: Make a "yes" path leaving the diamond and a "no" path leaving the diamond.

STEP 4: Create a "result" for the "yes" and a result for the "no".

STEP 5: At least one of the "results" for the "yes" or "no" must be another CONDITIONAL (choice that must be made).

STEP 6: Create "yes" and "no" pathways for that condition.

** CONTINUE until you have a flowchart that has at least 3 "decisions/conditions" in  it.

There is an example  to the right.


Note : this flowchart does not follow the pseudocode convention of putting the conditional statements into diamond shapes, but it is still a fun example of how conditionals work.