In this tutorial, you will learn how to combine text and variables in Python to create messages that can change while your program is running. This is useful for displaying scores, names, levels, or any other information that updates dynamically, without needing to store the entire message in a separate variable first.
To access the full video please subscribe to FLLCasts.com
- #2600
- 12 Mar 2026
Python allows you to build strings from smaller pieces. You can combine fixed text (such as "Score: ") with variables (such as score) by using the "+" symbol.
Example:
from hub import light_matrix import runloop score = 10 async def main(): # Display the score message = "The score is: " + str(score) light_matrix.write(message) runloop.run(main())
Here is what happens:
"The score is: " is fixed text.
str(score) converts the number into text so it can be combined with the message.
The final result becomes "The score is: 10".
You can also combine the text and variable directly inside the brackets.
from hub import light_matrix import runloop score = 10 async def main(): # Display the score light_matrix.write("The score is: " + str(score)) runloop.run(main())
Courses and lessons with this Tutorial
This Tutorial is used in the following courses and lessons
Level A: Python Foundations – Robotics with LEGO SPIKE Prime
This is the first level of the LEGO Robotics Curriculum with Python, designed for students in grades 2, 3, and 4.
In this robot adventure, students learn to control robots using real Python code, while teachers guide them through their first steps in text-based programming. Throughout the level, students build a variety of LEGO SPIKE Prime robot models and program them to move, turn, and complete tasks with increasing precision.
Step by step, students learn how to read, understand, and write their own Python programs. Through fun and creative challenges, they bring their robots to life and discover how code can control movement, solve problems, and interact with the world. Along the way, they explore concepts such as navigation, obstacle avoidance, and sensor-based behavior.
The curriculum is designed to help teachers introduce programming in an engaging and approachable way while giving students plenty of opportunities to experiment, test ideas, and develop confidence in their coding skills.
By the end of the level, students apply everything they have learned in an exciting robotics competition. Using their own programs and robot designs, they complete missions on a competition field with boxes, putting their coding, engineering, and problem-solving skills to the test.
- 46
- 4:32
- 78
Lesson 5 - Educational toy: Learn to read the clock
Remember to give students regular feedback. It is important to provide clear and structured feedback, including grades or ranks. Today, you will need to assess your students by following this article.
- 7
- 6
- 14
- 3d_rotation 1