Introduction to Python

Activity 1: Addition Bot

Lesson 4: Variables and Data Types

In this activity, we will build an Addition Bot — a Python program that asks the user for two numbers and displays their sum, along with a friendly message from Tobi!

Tobi the bear wearing a robot helmet standing next to large plus and equals signs with the label Addition Bot

Setting Up

  • Open PictoBlox and create a New File.
  • Select Python as the coding environment.
  • Make sure the Tobi sprite is on the Stage.

Writing the Script

# Addition Bot tobi.say("Hi! I am the Addition Bot!", 2) tobi.say("Give me two numbers and I will add them for you!", 2) num1 = float(input("Enter the first number: ")) num2 = float(input("Enter the second number: ")) result = num1 + num2 tobi.say("The sum of " + str(num1) + " and " + str(num2) + " is " + str(result), 3)

Running the Script

  • Click Run to start the program.
  • Enter the first number in the input box and press Enter.
  • Enter the second number and press Enter.
  • Watch Tobi announce the result!
PictoBlox stage showing Tobi saying the sum of two numbers entered by the user

Challenge

Extend the Addition Bot to also display the difference, product, and quotient of the two numbers — making it a full arithmetic bot!

Save your file with the name Addition Bot before moving on!

Subscribe to our newsletter.

Get updates to news and events.