Boolean Expressions: true or false
Learn Alice in FREE step-by-step lessons.
Module 11: Boolean Expressions: true or false
The goal of this lesson is to learn to use Boolean expressions to make comparisons.
You will learn to use the if/else control structure to create different paths or branches in the code.
Sometimes a programmer would like one statement, or group of statements to execute only if certain conditions are true. There may be a different statement, or group of statements that are to be executed when the condition is false. An expression that can be evaluated to true or false is called a Boolean expression. (Named after a mathematician named Boole who developed Boolean algebra.)
In this module, you will use Boolean Expressions. Boolean expressions are ones that can be evaluated as true or false.
You will use if/else control structures to control which code to execute.
You will perform tasks such as asking the user a question and tell if the answer is right.
Your Guessing Game program will ask the user a series of questions. You will use Boolean expression to determine if the answer is right or wrong and tell the user his score at the end of the quiz.
In order to do this you will:
- Write code to input answers of various types from the user.
- Apply if/else control structures to tell the user if his answer is right or wrong.
- Implement a counter to display the score at the end.
- Use the function getBooleanFromUser to get true or false answers.
- Write code to compare values and take appropriate actions.
- Be able to use AND and OR in Boolean expressions.
- Use the function getHeight to find the taller of two animals.