Logic and choice
In this chapter we will learn more about how computers use logic and can choose between different options. In this way, our programs become smarter!
Your alarm clock (or the alarm on your phone) has a simple if statement: Is the current time equal to the time saved? If so, the alarm should ring, and otherwise nothing happens.
Alarm systems for houses or office buildings use various sensors that tell if a door has been opened or if they have seen any movement. The information comes to the computer as with the if-statement "has any sensor sent a signal?" starts calling the emergency center.
Difficulty level
- Indentation
- Which one is right? 1
- Which one is right? 2
- Correct if-statement
- What satisfies the condition? 1
- What satisfies the condition? 2
- No intended lines
- What gets printed?
- What is the difference?
- What gets printed? 1
- What gets printed? 2
- What gets printed? 3
- Infinite loop
- What gets printed?
- Infinite loop 2