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.
Необходимо е да се абонирате за 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())
Курсове и занятия включващи този Урок
Този Урок е използван в следните курсове и занятия.
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
Важно е да даваме обратна връзка на учениците си и се стремим да го правим редовно по време на курса. По-долу ще намерите описание на ранговете, които използваме в училището по роботика, както и на качествата и поведението, които ги определят.
Днес трябва да поставите рангове на учениците си според инструкциите тук.
- 7
- 6
- 14
- 3d_rotation 1