Build Your Own AI Assistant Part 1 - Creating the Assistant
115007 Views
Is the new Raspberry Pi AI Kit better than Google Coral?
103855 Views
Control Arduino with Python using Firmata / PyFirmata
86426 Views
How to Map with LiDAR - using a Raspberry Pi Zero 2W, RPLidar and Rviz
55270 Views
Node-Red Automation, MQTT, NodeMCU & MicroPython
51306 Views
Creating a Supercomputer with a Raspberry Pi 5 Cluster and Docker Swarm!
50568 Views
Installing and Using DeepSeek-R1:1.5 on a Raspberry Pi with Docker
Gamepad & BurgerBot
Level Up your CAD Skills
Operation Pico
Raspberry Pi Home Hub
Hacky Temperature and Humidity Sensor
Using the Raspberry Pi Pico's Built-in Temperature Sensor
0h 24m
Getting Started with SQL
0h 32m
Introduction to the Linux Command Line on Raspberry Pi OS
0h 42m
How to install MicroPython
0h 8m
Wall Drawing Robot Tutorial
0h 22m
BrachioGraph Tutorial
0h 16m
Learn Linux from the basics to advanced topics.
Learn how to use a Raspberry Pi Pico
Learn MicroPython the best language for MicroControllers
Learn Docker, the leading containerization platform. Docker is used to build, ship, and run applications in a consistent and reliable manner, making it a popular choice for DevOps and cloud-native development.
Learn how to build SMARS robots, starting with the 3D Printing the model, Designing SMARS and Programming SMARS
Learn how to build robots, starting with the basics, then move on to learning Python and MicroPython for microcontrollers, finally learn how to make things with Fusion 360.
Learn Python, the most popular programming language in the world. Python is used in many different areas, including Web Development, Data Science, Machine Learning, Robotics and more.
Learn how to create robots in 3D, using Fusion 360 and FreeCAD. The models can be printed out using a 3d printer and then assembled into a physical robot.
Learn how to create Databases in Python, with SQLite3 and Redis.
KevsRobots Learning Platform
40% Percent Complete
By Kevin McAleer, 3 Minutes
Lets create a simple program that will display the message ‘Hello World’1.
First, here is the code, type this into your MicroPython editor:
print ("Hello World!")
When we run this, we will see the following printed to our screen (also refered to as the console):
Hello World!
To run this in Thonny, click the green run button:
run
As you can see this is a very simple piece of code. The word print is a special word that Python understands. Python expects a line of text between the brackets, inside of the speech marks.
print
Notice that the print command is in lowercase; typing Print or PRINT will result in an error message.
Print
PRINT
We call this case sensitive; we need to ensure that the commands we type are in the correct case for Python to work properly.
Congratulations, you’re now a MicroPython programmer!
Note The pound (or hash) symbol # means the reset of the line is a comment MicroPython ignores comments, so you can type useful reminders or notes to others here: # a single line comment For comments that span multiple lines, you can use 3 double quotations: """ This is a multi - line comment """
The pound (or hash) symbol # means the reset of the line is a comment MicroPython ignores comments, so you can type useful reminders or notes to others here:
#
# a single line comment
For comments that span multiple lines, you can use 3 double quotations:
""" This is a multi - line comment """
But why do we use the word print? It doesn’t come out of my printer?
Back in the early days of computing there were no screens, just a form of electronic typewriter that would print out the results of programs running on the attached computer. These terminals were called teleprinters or teletype machines which is why serial devices in Unix have the prefix TTY. A lot of computing stems from these early days and still remains in some form.
teleprinters
teletype
TTY
We put the hello world message in speech marks so that the computer knows where our message starts and ends. The speech marks can be either ' ' single or " " double quotes.
hello world
starts
ends
' ' single
" " double
Quotes In MicroPython you can use double " " or single quotes ' ' when working with text strings, the preferred method is to use double quotes: read the Black style guide for more background on this. Double quotes anticipate the need for apostrophies within text so it makes sense to use them by default.
In MicroPython you can use double " " or single quotes ' ' when working with text strings, the preferred method is to use double quotes: read the Black style guide for more background on this. Double quotes anticipate the need for apostrophies within text so it makes sense to use them by default.
" "
' '
We use the brackets ( ) to tell the computer that we want to run a function (a named block of code), the function named print.
( )
function
Also notice that the commands are in lowercase - no capital letters, this is because MicroPython (and Python) are case sensitive meaning the words print, Print and PRINT are not all the same.
lowercase
case sensitive
The print function is built-in to MicroPython, it already knows how to print things, so we don’t have to include any extra commands to make that work
This is a tradition that many programming language tutorials use to help you understand how to write a simple program. ↩
< Previous Next >