Introduction to Programming

Activity 1: Making an Addition Calculator

Lesson 5: Arithmetic Operators

In this activity, we will build a simple addition calculator in PictoBlox. The program will ask the user to enter two numbers, add them together, and display the result using a sprite.

Setting Up

  • Open PictoBlox and create a New File.
  • Select Block Coding as the coding environment.
  • Choose any sprite — we will use Tobi for this activity.

Creating the Variables

  • Go to the Variables palette and click Make a Variable.
  • Create a variable called Number1.
  • Create another variable called Number2.
  • Create a third variable called Result.

Building the Script

Now let's build the script. You will find the blocks in the mentioned palettes:

  • When flag clicked — Events
  • Ask (Enter the first number:) and wait — Sensing
  • Set (Number1) to (answer) — Variables
  • Ask (Enter the second number:) and wait — Sensing
  • Set (Number2) to (answer) — Variables
  • Set (Result) to (Number1 + Number2) — Variables & Operators
  • Say (join (The answer is: ) (Result)) for (3) seconds — Looks & Operators
Block coding script in PictoBlox showing when flag clicked, two ask and wait blocks saving answers to Number1 and Number2, set Result to Number1 + Number2, and say the result

Running the Script

  • Click the green flag to start the program.
  • Enter the first number when prompted and press Enter.
  • Enter the second number when prompted and press Enter.
  • Watch Tobi display the sum of the two numbers in a speech bubble!
PictoBlox stage showing Tobi with a speech bubble displaying the result of the addition, with Number1, Number2, and Result variables visible

Challenge

Try extending the calculator to support all four operations — addition, subtraction, multiplication, and division. You could ask the user which operation they want to perform, then carry it out!

Save your file with the name Addition Calculator before moving on to the next activity!

Subscribe to our newsletter.

Get updates to news and events.