MOCKSTACKS
EN
Questions And Answers

More Tutorials









Raspberry Write Your First Program Hello World!


Just as a young child learns to crawl before they walk, programmers learn how to output “Hello, world" as the first step in learning a new language. Now, let's take a look at how to write your first program.

First, connect Pico to the computer using a USB cable; then, open Thonny, and click on the “restart back-end process" button on the toolbar. If you successfully connect Pico to your computer, you will see the MicroPython version information and device name returned by Pico in the Shell area.

After connected, click on the Shell area and type the instruction:

print("Hello, World!")

print() is a common function used as a printout. When you need to output some data to the Shell, you can use this function.

When you press ENTER after you type the instruction, you’ll see the execution result of the input instruction is displayed in the Python Shell area, which means, the message “Hello, World!" is printed out in the Python Shell area.

Now let's try to type the same instruction in the script area. When you press ENTER this time, nothing happens — except that a new, blank line is created in the script.

To make your program in the script work, you'll have to click the “Run current script" button in the toolbar.

If you are running a new program that has never been saved, then when you click the “Run current script" button, Thonny automatically shows you a menu with two options — save the program to “This computer" or “Raspberry Pi Pico". You can choose where to store the program according to your own needs. Once your program is saved, you'll see the execution result of the program in the Shell area.

·Note·

Where should I save the program?
To be honest, there's no definitive answer. Where you save your program depends on your needs. If you want to show your program to your friends, you should save it to your Pico and take it with you. If you simply want to save the program for later use, just save it to your computer.

The next time you want to open your saved program, click the “open" button on the toolbar to find the corresponding program.

Conclusion

In this page (written and validated by ) you learned about Raspberry Write Your First Program Hello World! . What's Next? If you are interested in completing Raspberry tutorial, your next topic will be learning about: Raspberry Hardware and Programming.



Incorrect info or code snippet? We take very seriously the accuracy of the information provided on our website. We also make sure to test all snippets and examples provided for each section. If you find any incorrect information, please send us an email about the issue: mockstacks@gmail.com.


Share On:


Mockstacks was launched to help beginners learn programming languages; the site is optimized with no Ads as, Ads might slow down the performance. We also don't track any personal information; we also don't collect any kind of data unless the user provided us a corrected information. Almost all examples have been tested. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. By using Mockstacks.com, you agree to have read and accepted our terms of use, cookies and privacy policy.