Welcome to Relational Operations!

In this part of your Computer Science journey, we are going to learn how computers make decisions. Have you ever wondered how a game knows when you’ve beaten a high score, or how a website knows if your password is the right length? It all comes down to Relational Operations. Don't worry if this seems a bit technical at first—by the end of these notes, you'll see that it's just like comparing things in real life!

What are Relational Operations?

In programming, a relational operation is simply a way to compare two values. When we compare these values, the computer gives us an answer of either True or False. Think of it like a referee in a football match: they look at a tackle and decide "Yes, that's a foul" (True) or "No, it isn't" (False).

Did you know? Because these operations only result in True or False, they are often used inside Selection (IF statements) and Iteration (Loops) to control how a program runs.


The Six Essential Operators

According to the AQA syllabus, there are six operators you need to be familiar with. Let's break them down using simple examples.

1. Equal to

This checks if two values are exactly the same.
Example: Does 5 equal 5? True.
Example: Does "Apple" equal "Orange"? False.

2. Not equal to

This checks if two values are different. It is the opposite of "Equal to".
Example: Is 5 not equal to 10? True.
Example: Is 10 not equal to 10? False.

3. Less than

This checks if the value on the left is smaller than the value on the right.
Example: Is 3 < 10? True.
Example: Is 10 < 3? False.

4. Greater than

This checks if the value on the left is bigger than the value on the right.
Example: Is 50 > 20? True.
Example: Is 10 > 10? False (because they are the same!).

5. Less than or equal to

This checks if the value on the left is either smaller than OR exactly the same as the value on the right.
Example: Is 10 <= 10? True.
Example: Is 5 <= 10? True.

6. Greater than or equal to

This checks if the value on the left is either bigger than OR exactly the same as the value on the right.
Example: Is 18 >= 18? True (Useful for checking if someone is old enough to vote!).
Example: Is 21 >= 18? True.

Key Takeaway: Relational operators are the "questions" a program asks to decide what to do next. Every operation results in a Boolean value (True or False).


Real-World Analogy: The Theme Park

Imagine you are standing at the entrance to a roller coaster. The sign says: "You must be 1.4 meters or taller to ride."

In programming, the "Logic Gate" at the front of the queue would look like this:
IF height >= 1.4 THEN
    Allow the person on the ride
ELSE
    Sorry, you are too short!


Watch Out! Common Mistakes

Even the best programmers make these mistakes sometimes! Keep an eye out for these when writing your code or answering exam questions:

1. The Single vs. Double Equals: In many languages (like Python), a single = is used to assign a value to a variable (e.g., score = 10). A double == is used to compare two values (e.g., IF score == 10).
2. The Order of Symbols: For "Greater than or equal to," the symbol always comes first, followed by the equals sign: >=. Writing it as => will usually cause an error!
3. Comparing Different Types: Trying to check if the number 10 is greater than the word "Banana" will confuse the computer!


Quick Review Box

Memory Aid: Think of the < and > symbols as hungry crocodiles. The crocodile always wants to eat the bigger number!
\( 10 > 5 \) (The crocodile eats the 10)
\( 2 < 8 \) (The crocodile eats the 8)

Check your understanding:

What is the result of these comparisons?
1. 10 != 10 (Answer: False)
2. 15 >= 10 (Answer: True)
3. 5 < 5 (Answer: False - because 5 is not less than itself!)


Summary of Operators by Language

The AQA syllabus mentions that different languages use different symbols. While the concepts stay the same, the symbols might look slightly different:

Equal to: usually == (Python/C#) or = (VB.NET/Pseudo-code)
Not equal to: usually != (Python/C#) or <> (VB.NET/Pseudo-code)
Greater/Less than: almost always > and <

Key Takeaway: Always check which language the exam question is asking for, but remember that the logic of how they work never changes!