Introduction to Programming

Relational Operators

Lesson 6: Conditional Statements

What are Relational Operators?

In real life, we make decisions based on comparisons all the time — 'Is it raining? Then take an umbrella.' In programming, we make comparisons using relational operators. These operators compare two values and return either true or false.

A relational operator compares two values and returns a Boolean result — either true or false. These are also called comparison operators.

Relational Operators in PictoBlox

PictoBlox provides relational operator blocks in the Operators palette. They are represented as hexagonal blocks because they return a true/false value.

Relational Operators in PictoBlox

OperatorSymbolExampleResult
Greater than>8 > 5true
Less than<3 < 7true
Equal to=4 = 4true
Not equal to5 ≠ 3true
Greater than or equal to5 ≥ 5true
Less than or equal to3 ≤ 6true
PictoBlox Operators palette showing relational operator blocks including greater than, less than, and equal to

Boolean Values

Relational operators always return a Boolean value. A Boolean can only be one of two things: true or false. These values are the foundation of decision-making in programming.

Boolean values are named after mathematician George Boole, who developed the algebra of logic. Every condition in programming ultimately reduces to true or false.

Using Relational Operators with Variables

Relational operators are most useful when comparing variables. For example, you can check if a player's score is greater than 10, or if a sprite's x position is less than 0.

Block coding example showing a relational operator block comparing variable Score to 10 using greater than operator

Subscribe to our newsletter.

Get updates to news and events.