Tuesday, 2 January 2018

3) Conditional operators


Conditional operators

Conditional operations can be done using the boolean commands found in flow palette.

Repeat command:
The repeat block makes the turtle repeat instructions that are attached to it. How many times will the turtle repeat the instruction it depend from the value in the purple tab. This example draws a square, moves forward 100 spaces then turns right 90 degrees. This command repeats 4 times.

If-then command:
The if/then block is used when the expression between the if and then keywords must has a boolean result type – True/False. If the expression evaluates to 'True' then the statement following the keyword 'then' is executed. If the expression evaluates to 'False' , then the loop is closed and passes on to the next instruction.

If-then- else command:
The if/then/else block is similar to the if/then block, but has an instruction for the result false also. If the expression evaluates to 'True' then the statement following the keyword 'then' is executed. If the expression evaluates to 'False' , then the statement following the keyword 'else' is executed.

While command:
The while block execute the commands under right flow while the condition is true.

Forever command:
The forever block continuously repeat the instructions under the right flow.

No comments:

Post a Comment

1) Introduction to Email

Introduction to Email Introduction Communication, the transfer of information, has been the key element needed ...