Computer Science Grade 7 20 min

8. Boolean Logic: True and False

Introduce Boolean logic (AND, OR, NOT) and its importance in computer science.

Tutorial Preview

1

Introduction & Learning Objectives

Learning Objectives Define Boolean logic and its two values, True and False. Identify and use the six main comparison operators (==, !=, >, <, >=, <=). Evaluate a simple comparison expression to determine if it is True or False. Write a conditional statement that results in a Boolean value. Explain how Boolean logic is used to make decisions in computer programs, like in an 'if' statement. Predict the outcome of a simple code block based on a Boolean condition. Have you ever played a game where you had to choose a door? 🚪 Your choice is either right or wrong. Computers make billions of these simple 'yes' or 'no' decisions every second! This lesson introduces you to Boolean logic, the computer's way of thinking in 'True&#0...
2

Key Concepts & Vocabulary

TermDefinitionExample BooleanA data type that can only have one of two values: True or False. It's the simplest way to represent a 'yes' or 'no' answer.The statement 'The sky is blue' can be considered True. The statement 'Pigs can fly' is False. TrueA Boolean value that represents a 'yes', 'on', 'correct', or '1'. It means a condition has been met.In the expression `5 > 3`, the result is True. FalseA Boolean value that represents a 'no', 'off', 'incorrect', or '0'. It means a condition has not been met.In the expression `10 == 20`, the result is False. ConditionA question or expression that the computer can evaluate to be either True or False.`player_score >...
3

Core Syntax & Patterns

Equality and Inequality Operators `==` (is equal to) `!=` (is not equal to) Use `==` to check if two values are exactly the same. Use `!=` to check if they are different. These are essential for checking passwords, user input, or specific game states. Relational Operators `>` (greater than) `<` (less than) `>=` (greater than or equal to) `<=` (less than or equal to) Use these operators to compare numerical values. They are perfect for checking scores, ages, temperatures, or any value that can be measured on a scale.

4 more steps in this tutorial

Sign up free to access the complete tutorial with worked examples and practice.

Sign Up Free to Continue

Sample Practice Questions

Challenging
You are designing a game where a player gets a 'Perfect Score' bonus if their `score` is exactly 10,000. Which Boolean expression correctly represents the condition for this bonus?
A.score > 10000
B.score >= 10000
C.score == 10000
D.score != 10000
Challenging
A programmer writes `if (user_age = 18):` to check if a user is 18. The code doesn't work as expected. Why is this code incorrect for checking the user's age?
A.It should use the '<=' operator instead.
B.It uses the assignment operator '=' instead of the comparison operator '=='.
C.The number 18 should be in quotation marks like '18'.
D.The variable name should be 'age' instead of 'user_age'.
Challenging
A program runs a function to open a door based on a Boolean variable: `if (is_unlocked): open_door()`. For the `open_door()` function to run, what must be the value of `is_unlocked`?
A.False
B.True
C.1
D.Open

Want to practice and check your answers?

Sign up to access all questions with instant feedback, explanations, and progress tracking.

Start Practicing Free

More from II. Data Representation & Binary Basics

Ready to find your learning gaps?

Take a free diagnostic test and get a personalized learning plan in minutes.