"Python is a great way to deepen your programming skills through text-based coding. Its natural English-like structure makes it easy to start learning, but it’s also powerful enough to be used in areas like data science and machine learning. Our Python editor is designed to help coders get the most out of text-based programming on the micro:bit."
The Reference (#1 & 2) and API (#7) tabs on the left side provide detailed information about code commands, and the way they need to be used (syntax).
The Ideas tab, (just under the “Reference” tab, provides already-created MicroPython code for a variety of micro:bit projects, explains them in detail and suggests challenges to modify it to help you learn. If you want more detail, scroll down and click on the “More ideas” link. There you will find those ideas and more, but with video tutorials and a link to get the code in MicroPython.
#3 - Python coding language, like most text-based coding languages,relies on specific and special characters such as uppercase or lowercase letters, parentheses () and colon : as well as space created by pressing the Tab button. This is part of the syntax of the language and if the coder is not exact, it can result in the code not running, or running in an unexpected way. This is because the basic computers on microcontrollers do NOT infer - that is, they are unable to figure things out, they do exactly and only what the code tells them to do.
If there are errors in the code, the editor will let you know what line the error is on with an orange circle (#4)
Similar to the MakeCode editor, as you begin typing, the editor will provide a list of suggested code to select. (#5)
Even if you don’t have an actual micro:bit connected, the editor has a built-in simulator (#6) that will simulate the code you’ve written. There are tools & sliders under it where you can virtually adjust the conditions to simulate how your micro:bit and code would react to changing sensor input such as tilt, movement/shake, light, sound, temperature, etc.
Here is a video that explains what is written above.
Python Editor Guide:
https://support.microbit.org/support/solutions/articles/19000135210-python-editor-guide
Link to the Python Editor:
Let’s do it in micro:bit Python!!
The micro:bit Python Code Editor opens up with some sample code to display a heart. The line of code on line 2 that reads:
from microbit import *
MUST stay in your code script, if you delete it, your code will not work! This line of code directs the editor to hidden/background code that translates the Python you write to what the micro:bit understands. So be careful when you are making your new code or editing existing code.
Also, FYI, in Python, if you see a line that begins with a pound sign/hashtag/number sign (#), it tells the computer or microcontroller that everthing on that line is actually text for the humans reading the code, not for the computer, so it will ignore those lines. Coders often leave themselves or other coders notes about their code to help remember what their code did when they review it later.
One last thing to note: Unlike MakeCode and TinkerCad, micro:bit Python Editor does not allow users to create an account to save their work to the cloud, so... if you want to continue working on your code another time, you will need to download/save it to your computer, and then when you open the editor again, you will need to upload/import the code back into the editor.
(DON'T FORGET to change your browser's settings to ASK you where you want the file to go each time you save!)