Loading...

if else - part 1

__info__

BOB3 is going to reveal the truth! We’re going to programme BOB3 to recognise true and false by giving a him a question: If it’s true, the lights should light green, otherwise they should be red.

__info__

To programme this, we use if-else:

BOB decides which block to run by checking to see if the condition in line 12 is true or false: == means “equals” 1 == 1 is true 1 == 3 is false The compiler executes
  • either all the commands in the if block
  • or all the commands in the else block.

A block is all the commands in curly brackets/braces { }.

Er entscheidet sich für einen Block, indem er die Bedingung in Zeile 12 auf wahr oder falsch prüft:
1 == 1

== bedeutet "genau gleich"

1 == 1 ist wahr

1 == 3 ist falsch

__task__

Compile the program and test it on your BOB3.

What happens?

__task__

1 == 3

Compile the program and test it on your BOB3.

What happens now?

__task__

8 == 8

What do you expect will happen?

Compile the program and see if you’re idea was right!

__quiz__

1: True or false: 9 == 6 
2: True or false: 155 == 155 
3: True or false: 8 == 5+3 
4: True or false: 14 == 20-5 
 You haven’t completed anything yet!
 Super, so far so good…
 Super, you got it all right!
 Sadly not correct…
 One answer is correct
 A couple are correct…