AllTheTimeWorld.com

alice booleanBoolean Expressions: true or false

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:

Print the lesson

Please study the material at each of the links below.

  1. Ask if it is nighttime Ask if it is nighttime: The function getBooleanFromUser gives a choice of true or false.
    /alice/videos/alice-boolean.mp4

  2. Using Boolean Expressions in If Block Using Boolean Expressions in If Block: Ask if Thor is happy, he says ha-ha or boo-hoo
    /alice/videos/alice-boolean-if.mp4
  3. Pass or Fail Pass or Fail: Compare a score to 65 and say "Pass" or "Fail"
    /alice/videos/alice-pass-fail.mp4
  4. Child or Adult? Comparing values Child or Adult? Comparing values: Compare age to determine if child or adult
    /alice/videos/alice-child-adult.mp4
  5. Restaurant? Using AND: && Restaurant? Using AND: &&: Need restaurant with hamburgers and pizza
    /alice/videos/alice-restaurant.mp4
  6. Teenager? Using AND: && Teenager? Using AND: &&: You are a teenager if age >=13 AND age <= 19
    /alice/videos/alice-teenager.mp4
  7. Panda says "Whee!" if turning fast: Panda says "Whee" if amountToTurn > 2.0

  8. Who is taller? Finding larger of 2 Who is taller? Finding larger of 2: Use the function getHeight to find the taller of two animals
    /alice/videos/alice-taller.mp4
  9. A Quiz Game A Quiz Game: This video shows how to create a quiz and keep track of number right.
    /alice/videos/alice-quiz.mp4
  10. A True/False Question: Using if to tell the user the answer is right.

  11. A drill on Boolean values A drill on Boolean values: See if you can do these comparisons

  12. The user is offered coffee and tea The user is offered coffee and tea: See if you can add another choice
    /alice/videos/alice-coffee-tea-soda.mp4
  13. The seagull asks how many penguins there are. The seagull asks how many penguins there are.: See if you can add to this project
    /alice/videos/alice-how-many-penguins.mp4
  14. Self Study Questions Self Study Questions: What have you learned?

  15. Discussion Questions Discussion Questions

Active Learning

Create a guessing game or quiz.