Alice Programming
Learn Alice in FREE step-by-step lessons.
Module 12: Boolean Expressions: true or false
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.
Goal:
- Use Boolean expressions to make comparisons
- Use the if/else control structure to create different paths or branches in the code
- Perform tasks such as asking the user a question and tell if the answer is right
- Gain a deeper understanding of objects in the Alice virtual world
In order to do this you will:
Objectives:
- 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.