Skip to content
Lessons JSS 1 Digital Technologies Basic Computer Programming

Conditional Statements, Relational and Logical Operators in Programming for JSS 1

Students develop practical understanding of conditional statements, relational and logical operators in programming through demonstrations and guided computer activities. They learn the key concepts, practise relevant digital skills and apply safe, responsible habits when using technology and information.

Digital Technologies illustration
Study comfort0% read
Curriculum at a glance Your lesson roadmap Class, subject, theme and the learning goal for this lesson.
Class JSS 1
Subject Digital Technologies
Theme Basic Computer Programming
Topic Control with Conditions in programming
Curriculum September 2025
Sequence 15
Learning outcome

Create programs using visual programming language

Focal competence

Displaying programming skills to create interactive programs

ARTICLE CONTENTSOn this page 9 sections

Control with Conditions in Programming

Performance Objectives

By the end of the lesson, students should be able to:

  1. explain the following: conditional statement, relational operators and logical operators;
  2. identify conditional statement, relational operators and logical operators in a program;
  3. apply conditional statements to create a program.

Meaning of Conditional Statements

A conditional statement is a programming instruction that directs a computer to perform specific actions only when a certain condition is true or false.

In computer programming, decisions are made based on conditions. A condition is a state or a situation that can be evaluated as either true or false. If the condition is met (true), the computer executes a specific set of instructions. If the condition is not met (false), the computer either skips those instructions or executes an alternative set of instructions.

A common real-world analogy is found in the popular Nigerian card game, WHOT. A player must follow specific rules to play a card. For example, a player can only play a card if the shape matches the card on top of the pile, or if the number matches. This decision-making process is a conditional statement: “If the card matches the shape, then play the card.”

Another everyday example is the rule for voting in Nigeria. A person can only register to vote if they are 18 years of age or older. The condition is “age is 18 or older”. If this condition is true, the person is allowed to vote. If it is false, the person is not allowed to vote.

Conditional Blocks in Scratch 3.0

In Scratch 3.0, conditional statements are represented by specific control blocks. These blocks have hexagonal slots where conditions are placed.

The primary blocks used for expressing conditional statements in Scratch are:

  1. The “if-then” block: This block checks a condition. If the condition is true, the blocks inside the “if-then” block are executed. If the condition is false, the program skips them.
  2. The “if-then-else” block: This block provides two paths. If the condition is true, the program runs the first set of blocks. If the condition is false, the program runs the second set of blocks under the “else” section.

Observe the diagram below to see how these blocks are structured in Scratch.

Relational Operators

A relational operator is a symbol used to compare two values or expressions to determine the relationship between them.

Relational operators compare values such as numbers, variables or text. The result of this comparison is always a boolean value, which means it is either true or false. These operators are essential for creating the conditions used in conditional statements.

The three main relational operators used in JSS 1 programming are:

  1. Greater Than (>): This operator checks if the value on the left is larger than the value on the right. For example, 25 > 20 is true.
  2. Less Than (<): This operator checks if the value on the left is smaller than the value on the right. For example, 15 < 20 is true.
  3. Equal To (=): This operator checks if the value on the left is exactly the same as the value on the right. For example, score = 50.

In Scratch 3.0, these operators are represented by green hexagonal blocks. They are located in the “Operators” category.

Look at the diagram below to see how relational operator blocks appear in Scratch.

Combining Logical Operators

Programmers often need to check multiple rules at the same time. This is done by nesting relational operator blocks inside logical operator blocks.

For example, to check if a student is eligible for a senior class, the program might need to verify if the student has completed JSS 3 and passed the basic education certificate examination. This requires combining two conditions using the AND operator.

The process of combining operators in Scratch involves the following steps:

  1. Select a green logical block, such as the “and” block.
  2. Drag a relational block, such as “greater than”, into the first hexagonal slot of the logical block.
  3. Drag another relational block, such as “equal to”, into the second hexagonal slot of the logical block.
  4. Place the combined green block into the hexagonal slot of an “if-then” or “if-then-else” control block.

An example of a combined condition in pseudocode is:

If (score > 50) AND (attendance > 75) then promote student.

Nested Conditional Statements

A nested conditional statement is a conditional statement that is placed inside another conditional statement.

Nesting is used when a program needs to make a series of decisions where the second decision depends on the outcome of the first decision. It allows for more detailed paths than a simple true/false choice.

A common example of nesting is a school grading system. To assign grades, the program must check multiple ranges of scores:

  1. First, check if the score is greater than 70. If true, the grade is “A”.
  2. If false, enter the “else” section and check another condition: is the score greater than 50? If true, the grade is “B”.
  3. If false, enter the next “else” section and check if the score is greater than 40. If true, the grade is “C”. If false, the grade is “F”.

Observe the diagram below to see how nested conditional blocks are arranged inside one another.

How to Create a Test Score Program in Scratch 3.0

This practical activity demonstrates how to apply conditional statements and relational operators to create a working program. The program asks a user to input a test score. If the score is greater than 20, the program displays a message saying the test has been passed. Otherwise, it displays a message saying the test has not been passed.

The required tools are:

  1. A computer or tablet with Scratch 3.0 installed, or access to the online Scratch editor.
  2. A keyboard and mouse for input.

The procedure involves the following steps:

  1. Open Scratch 3.0 on the digital device.
  2. Click on the Events category (yellow) and drag the when green flag clicked block to the workspace.
  3. Click on the Sensing category (light blue) and drag the ask [What's your name?] and wait block. Change the text inside the block to Enter your test score:.
  4. Click on the Control category (orange) and drag the if-then-else block, placing it directly underneath the ask block.
  5. Click on the Operators category (green) and drag the [ ] > [ ] (greater than) block. Place this green block into the hexagonal slot of the if-then-else block.
  6. Click on the Sensing category (light blue) again. Drag the answer block and place it into the first blank circle of the green greater than block.
  7. Type 20 into the second circle of the green greater than block. The condition should now read answer > 20.
  8. Click on the Looks category (purple). Drag a say [Hello!] for 2 seconds block and place it inside the first C-shaped mouth (the “then” branch) of the if-then-else block. Change the text from “Hello!” to Test passed!.
  9. Drag another say [Hello!] for 2 seconds block from the Looks category and place it inside the second C-shaped mouth (the “else” branch) of the if-then-else block. Change the text to Test not passed..
  10. Click the green flag above the stage to run the program. Type a number (for example, 25) into the input box and press enter to observe the output. Run the program again and type a lower number (for example, 15) to test the alternative path.

The diagram below shows the completed Scratch script for this program.

20′ block. Inside the ‘then’ branch is a purple ‘say Test passed! for 2 seconds’ block. Inside the ‘else’ branch is a purple ‘say Test not passed. for 2 seconds’ block.
alt: Completed Scratch 3.0 script for checking a test score.
caption: Completed Scratch 3.0 script for the test score program.
aspect_ratio: 4:3
–>

Summary of Key Programming Blocks

The table below summarizes the blocks and operators used to control program flow with conditions.

Block Type Scratch Category Function Example Use
If-Then Control (Orange) Runs blocks inside only if the condition is true. Checking if a key is pressed.
If-Then-Else Control (Orange) Runs one set of blocks if true, and another set if false. Checking if a score is a pass or a fail.
Relational Operators Operators (Green) Compares two values using >, <, or =. Checking if age is greater than 18.
Logical Operators Operators (Green) Combines multiple conditions using AND, OR, or NOT. Checking if a card is a Star OR a Circle.
Digital Technologies PRACTICE

Ready to test what you learned?

Check your understanding of Conditional Statements, Relational and Logical Operators in Programming for JSS 1 with a quick, focused quiz and instant feedback.

20 questions · Instant results · Retake anytime
Quick practice
KEEP YOUR MOMENTUMNext in Digital Technologies
16of 27
Basic Computer Programming

Loops in Programming

Keep the idea fresh by moving forward while it is still active in your mind.

Help another learner

Share this lesson

Know someone studying this topic? Send them this lesson so they can learn and practise too.

Community

0 comments

Open the discussion when you need it. Comments stay collapsed until requested so the initial article remains light.

Share with