Introduction to Python

Activity: Introduce Yourself with Tobi

Lesson 1: Python Introduction

In this activity, we will write our first real Python program in PictoBlox! We will use Python code to make Tobi the bear introduce himself on the Stage using speech bubbles.

PictoBlox Python mode showing Tobi the bear on the Stage and an empty Python code editor ready to type

Setting Up

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

Understanding the say() Function

In PictoBlox Python mode, sprites have built-in functions. The say() function makes a sprite display a message in a speech bubble, just like the 'Say () for () seconds' block in block coding.

Side by side comparison showing the Say block in block coding on the left and tobi.say() Python code on the right with an arrow between them

Sprite Speech Functions

FunctionWhat it DoesExample
say(message, duration)Makes the sprite say a message for a number of secondstobi.say("Hello!", 2)
print(message)Prints a message to the output consoleprint("Hello, World!")

Writing the Script

Now let's write the Python script to make Tobi introduce himself. Type the following code in the Python editor:

tobi.say("Hi! My name is Tobi.", 2) tobi.say("I am a bear who loves coding!", 2) tobi.say("Welcome to Python programming!", 2)

Running the Script

  • Click the Run button (green flag) to execute the code.
  • Watch Tobi display each message one after another on the Stage.
  • Each message stays on screen for 2 seconds before the next one appears.
PictoBlox stage showing Tobi the bear with a speech bubble saying Hi My name is Tobi

Challenge

Modify the script to make Tobi introduce YOU instead! Change the messages so Tobi says your name, your age, and your favorite hobby.

Save your file with the name Introduce Yourself before moving on!

Subscribe to our newsletter.

Get updates to news and events.