Step-by-Step Lesson

Learn: Comparison Operators

OCR GCSE J277 Computer Science specification

Ready to start this lesson?

Sign in to track your progress. 12 steps including 6 interactive questions.

Sign In to Start Learning
12 Steps6 Questions

Students also studied

Browse all

Steps in this lesson (12)

1
Text

Welcome!Welcome back! In this lesson, we will build on your knowledge of variables, selection, and iteration to explore comparison operators. These operators help us compare values and make decisions in our programs.By the end of this lesson, you'll understand how to use operators like ==, !=, , , >, and >= to control the flow of your code.

2
Text

What Are Comparison Operators?Comparison operators are used to compare two values. They return a Boolean result: either true or false. This is essential for decision-making in programming.For example, you can check if two numbers are equal, if one is greater than the other, or if they are not equal.

3
Text

Key Comparison OperatorsHere are the comparison operators we’ll focus on:==: Checks if two values are equal.!=: Checks if two values are not equal.: Checks if the first value is less than the second.: Checks if the first value is less than or equal to the second.>: Checks if the first value is greater than the second.>=: Checks if the first value is greater than or equal to the second.

4
Multiple ChoiceInteractive

Quick check: Which operator checks if two values are equal?

Start the lesson to answer this multiple choice question

5
Text

How Do Comparison Operators Work?Comparison operators compare two values and return true or false. For example:5 == 5 returns true because the numbers are equal.10 != 5 returns true because the numbers are not equal.7 returns false because 7 is not less than 3.

6
Fill in the BlankInteractive

The operator {{blank0}} is used to check if two values are not equal.

Start the lesson to answer this fill in the blank question

7
Text

Using Comparison Operators in ProgramsComparison operators are often used in conditional statements like if and while to control program flow. For example:if age >= 18: print('You are an adult')The program checks if age is greater than or equal to 18. If true, it prints a message.

8
MatchingInteractive

Match the items on the left with their correct pairs on the right

Start the lesson to answer this matching question

9
Text

Review Time!Well done! You've learned about the different comparison operators and how they work. Let's test your understanding with a few more questions.

10
Multi-SelectInteractive

Which of the following statements are true? (Select all that apply)

Start the lesson to answer this multi-select question

11
Math EquationInteractive

Match the items on the left with their correct pairs on the right

Start the lesson to answer this math equation question

12
Code CompletionInteractive

Match the items on the left with their correct pairs on the right

Start the lesson to answer this code completion question

Genie

Want to Learn More?

Get personalised lessons, quizzes, and instant feedback from your AI tutor.

Explore More Topics