How to Use Operator Blocks in Scratch | Full Guide with Live Coding & Examples

How to Use Operator Blocks in Scratch Full Guide with Live Coding & Examples

Introduction: Operator Blocks in Scratch

Watch the full tutorial here – How to Use Operator Blocks in Scratch | Full Guide with Live Coding & Examples | Kodex Academy

In the world of block-based coding, Scratch stands out as one of the best platforms for beginners to learn programming logic through interactive games, animations, and applications. One of the most powerful features in Scratch is its Operator Blocks — essential for handling math operations, logic comparisons, and string manipulations.

In this comprehensive Scratch programming tutorial, brought to you by Kodex Academy, we’ll explore:

  • What operator blocks are
  • How to use math operators in Scratch
  • Building a calculator
  • Making logic-based games
  • Working with strings
  • Enhancing Scratch games using operator blocks

Whether you’re building a game in Scratch or learning how to use operator blocks in Scratch, this guide has everything you need.

What Are Operator Blocks in Scratch?

Operator blocks in Scratch are green-colored blocks used to:

  • Perform mathematical operations
  • Create logic conditions
  • Handle text (string) manipulation
  • Introduce randomness

These blocks are crucial when you need decision-making logic, such as checking if a player wins a game, solving a math problem, or responding to user input.

Watch this section in the video: Operator Blocks Overview – YouTube

Operator Blocks in Scratch: Step-by-Step Coding

1. Arithmetic Operators in Scratch

Used for basic math calculations: addition, subtraction, multiplication, and division.

Addition

set [result v] to ((5) + (3)) // Result = 8
say (result)

Subtraction

set [result v] to ((10) - (4)) // Result = 6
say (result)

Multiplication

set [result v] to ((6) * (7)) // Result = 42
say (result)

Division

set [result v] to ((20) / (5)) // Result = 4
say (result)

Use Case:

Build a calculator in Scratch to let users perform these operations dynamically.

2. Pick Random Operator in Scratch

Used to generate random numbers within a specified range — useful in games and animations.

Example:

set [randomNumber v] to (pick random (1) to (10))
say (join [Your lucky number is: ] (randomNumber))

Use Case:

Create a number guessing game or randomize enemy movement in a game.

3. Comparison Operators in Scratch

Used to compare values and return either true or false.

Greater Than or Less Than

if <(score) > (50)> then
  say [You passed!]
else
  say [Try again!]
end

Equal To

if <(answer) = (10)> then
  say [Correct!]
else
  say [Wrong answer.]
end

Use Case:

Evaluate game conditions like winning or losing based on score or timer.

4. Logical (Boolean) Operators in Scratch

Used to combine or negate conditions.

AND

if <<(score) > (50)> and <(level) = [final]>> then
  say [Game Completed!]
end

OR

if <<(key space pressed?)> or <(key up arrow pressed?)>> then
  change y by (10)
end

NOT

if <not <(lives) > (0)>> then
  say [Game Over!]
end

Use Case:

Build advanced game logic where multiple conditions need to be met.

5. String Operators in Scratch

Used for text (string) manipulation, useful in quizzes, chats, or name-based logic.

Join Strings

say (join [Hello, ] [Alex]) // Output: Hello, Alex

Letter of a Word

say (letter (1) of [Scratch]) // Output: S

Length of String

say (length of [Scratch]) // Output: 7

Contains?

if <[Scratch] contains [t]> then
  say [Yes, 't' is in Scratch!]
end

Use Case:

Create a program that reads user names or builds a typing game.

6. Advanced Math Functions in Scratch

These are mathematical operators used for more complex calculations.

Modulus (Remainder)

if <((number) mod (2)) = (0)> then
  say [Even Number]
else
  say [Odd Number]
end

Use Case: Even/Odd number checker

Round

say (round (4.7)) // Output: 5
say (round (4.2)) // Output: 4

Use Case: Display whole numbers in score systems or quizzes.

Absolute (Abs)

say (abs (-20)) // Output: 20

Use Case: Distance calculations or physics-based games.

Operators Table

Operator TypeExample CodeUse Case
Arithmetic((5) + (3))Calculator, Score calculation
Pick Random(pick random (1) to (100))Games, AI randomness
Comparison<(score) > (50)>Game decision-making
Logical (Boolean)<<condition1> and <condition2>>Game level logic
String(join [Hello ] [World]), (length of [Hello])Chat apps, Text analysis
Modulus((number) mod (2))Odd/Even checker
Round(round (3.6))Clean display of decimal values
Abs(abs (-5))Game movement, physics

Hands-On: Make a Calculator in Scratch

Watch the Full Calculator Demo: Scratch Calculator Demo – YouTube

Features:

  • Takes two numbers as input
  • User selects the operation (+, -, *, /)
  • Displays result

Blocks Used:

  • ask (Sensing)
  • if-else (Control)
  • + - * / (Operators)
  • set variable (Variables)

Sample Code:

when green flag clicked
ask [What operation? +, -, *, /] and wait
set [operation v] to (answer)

ask [Enter first number] and wait
set [num1 v] to (answer)

ask [Enter second number] and wait
set [num2 v] to (answer)

if <(operation) = [+]> then
  set [result v] to ((num1) + (num2))
else
  if <(operation) = [-]> then
    set [result v] to ((num1) - (num2))
  else
    if <(operation) = [*]> then
      set [result v] to ((num1) * (num2))
    else
      if <(operation) = [/]> then
        set [result v] to ((num1) / (num2))
      end
    end
  end
end

say (join [Result: ] (result)) for (10) seconds

Learn how to make calculator in Scratch interactively.

Odd/Even Number Checker (Using Modulus)

Objective:

Check if a number is even or odd using the mod operator. Watch the Mod Operator Example

✅ Code:

when green flag clicked
ask [Enter a number:] and wait
set [num v] to (answer)

if <((num) mod (2)) = (0)> then
  say [The number is even] for (10) seconds
else
  say [The number is odd] for (10) seconds
end

Great example for teaching math operations using Scratch.

Enhancement Features

Here are extra enhancements you can build into your Scratch projects using operator blocks:

1. Input Validation

Make sure the user enters numbers:

if <not <(answer) contains [0,1,2,3,4,5,6,7,8,9]>> then
  say [Please enter a valid number!]

2. Custom Result Display with Looks Block

switch costume to [resultDisplay v]
say (join [Your result is: ] (result)) for (5) seconds

3. Game Score Logic with Booleans

if <<(score) > (50)> and <(lives) > (0)>> then
  say [Level Complete!]
else
  say [Try Again!]

4. Mini Game with Random Numbers

set [target v] to (pick random (1) to (10))
ask [Guess a number from 1 to 10] and wait
if <(answer) = (target)> then
  say [Correct! 🎉]
else
  say [Wrong! It was ] + (target)

Conclusion: Mastering Operator Blocks in Scratch

Operator blocks are the backbone of logic, math, and text manipulation in Scratch programming. Whether you’re building a calculator, a logic-based game, or a text recognition app, understanding how to use these green-colored blocks unlocks a world of possibilities.

In this tutorial, you learned:

✅ How to use Arithmetic Operators for calculations
✅ How to apply the Pick Random block for dynamic behavior
✅ How to perform comparisons using Comparison Operators
✅ How to create logic using Boolean Operators like AND, OR, and NOT
✅ How to manipulate text with String Operators
✅ How to perform advanced operations with Modulus, Round, and Absolute Value

How to build Calculator in Scratch and How to build Odd/Even Number Checker

By mastering these, you’re not just learning Scratch — you’re building computational thinking skills that apply to all programming languages.

Call to Action

  1. Don’t forget to check out the full video tutorial: How to Use Operator Blocks in Scratch | Full Guide with Live Coding & Examples | Kodex Academy
  2. Like, comment & share the video
  3. Visit kodexacademy.com
  4. subscribe to the Kodex Academy YouTube channel for deeper Scratch content.

Happy coding with Kodex Academy! 🚀

Learn More with Kodex Academy

At Kodex Academy, we’re passionate about helping students learn coding in creative ways. This project teaches more than Scratch—it empowers young minds to build tools that work in the real world.

Explore more:

Stay updated with new content, free tutorials, and coding challenges!

Further Reading & Links

Recent Posts

How to Make a Math Racing Game in Scratch | Game Concepts and Complete Tutorial

In this tutorial, you’ll learn to build a Math Racing Game in Scratch. Players solve math problems to move their character forward; wrong answers benefit the opponent. It’s a race of speed, accuracy...

How to make Memory Skill Game in Scratch | Card Matching Game in Scratch – Part 2 | Step-by-Step Coding

In this tutorial you'll learn how to make memory skill game in Scratch / card matching game in Scratch. This is a great beginner‑to‑intermediate project for scratch tutorial game, scratch programming...

How to make a Card Matching Game in Scratch | Memory Skill Game in Scratch – Part 1 | Step-by-Step Coding

In this Scratch tutorial, we'll walk you through how to make a card matching game in Scratch, also known as a memory game or skill game. This is a popular beginner project that introduces essential...

Create a Quiz Game in Scratch | Spelling Test in Scratch | Picture Identification in Scratch

Want to make learning spelling fun, visual, and interactive? In this Scratch tutorial, you'll learn how to make a spelling quiz game in Scratch using picture identification, text-to-speech, and...

How to make a Double Jump Game in Scratch | Platformer game in Scratch | Step by Step Coding

How to make a Double Jump Game in Scratch. Scratch is a fantastic platform for beginners to learn programming by making games, animations, and interactive stories. Among the many kinds of games...

How to Use Variables in Scratch | Variable Blocks in Scratch | Complete Tutorial

Introduction: Variable Blocks in Scratch Whether you’re just getting started with Scratch programming or looking to take your projects to the next level, understanding variables and lists is...

How to Make Earth Revolve Around the Sun in Scratch: A Complete Tutorial & Enhancements

Animating Earth revolving around the Sun is a classic beginner/intermediate Scratch animation project. It combines trigonometry (sine & cosine), variables, loops, and visual scripting. Kids can learn...

How to Make a Game in Scratch | Snake Game in Scratch | Step-by-Step Game Coding

In this tutorial, we’ll build a Snake Grid style game in Scratch step by step (very similar to the Kodex Academy example). By doing this, you’ll cover many of the core Scratch building blocks. We will...

How to Use Operator Blocks in Scratch | Full Guide with Live Coding & Examples

One of the most powerful features in Scratch is its Operator Blocks — essential for handling math operations, logic comparisons, and string manipulations...

How to Create a Thirsty Crow Story in Scratch | Animation Story in Scratch for Kids

In this tutorial, you’ll learn how to create the classic “Thirsty Crow” story in Scratch, using simple animation, voice, and sprite actions. This is a perfect project for kids who are new to coding...

How to Create a Dodge Ball Game in Scratch: A Complete Step-by-Step Tutorial for Beginners

This step-by-step tutorial will guide you through how to create a Dodge Ball game in Scratch from scratch! In this game, you’ll control a character trying to dodge falling balls, earn points, and...

How to use Sensing Blocks in Scratch | Scratch programming for beginners | Live Coding with Examples

In today’s session, we’re diving deep into one of the most powerful features of Scratch — Sensing Blocks. These blocks allow your projects to interact with the world, detect touches, respond to...

Build an Egg Shooting Game in Scratch: Step-by-Step Coding | Complete Guide for Beginners

Learn how to create a fun, interactive shooting game in Scratch with this detailed tutorial inspired by classic arcade games. Perfect for kids and beginners looking to dive into Scratch programming!...

How to Make a Maze Game in Scratch | Step by Step Coding | Full Tutorial & Enhancements

Introduction: Why Build a Maze Game in Scratch? If you’re looking for a Scratch beginner project idea that’s fun, interactive, and educational, then building a maze game in Scratch is the...

Scratch Control Block Tutorial: Full Guide with Loops, Conditions, Cloning & Code Examples

“Control blocks” in Scratch are those blocks (from the Control category) that manage the flow of your script: when things happen, how many times they happen, making decisions, repeating actions...

How to Create a Car Racing Game in Scratch – Part 2 – Step-by-Step Coding

Welcome to your ultimate guide on how to make a car racing game in Scratch—a step‑by‑step tutorial. You'll learn Scratch game development techniques, see actual code blocks, and discover enhancements...

How to Make a Hurdle Jumping Game in Scratch – Build a Fun Hurdle Runner with Score & Win Screen

Are you ready to create your very own hurdle jumping game in Scratch—just like the iconic Chrome Dino or Super Mario? 🎮 Whether you're new to Scratch or just looking for your next fun project, this...

How to Create a Car Racing Game in Scratch – Part 1 – Step-by-Step Coding

In this Scratch car racing game tutorial, we’ll walk you through how to create a fully functional, visually exciting, and incredibly fun car racing game using Scratch. In this blog, we’ll cover: How...
Scroll to Top