Raspberry Hardware and Programming
Light up LED
Basic Program Structure
The programs that we write with MicroPython are generally composed of three basic program structures. Complex programs are built with a combination of these basic structures, so it is important to learn them first. They are: sequence structure, loop structure and selection structure.
Sequence Structure
Sequence structure is the most basic program structure. In sequence structure, programs run line-by-line, top-to-bottom, in turn. For example, when the following program runs, it prints “Hello" first, and then “World".
1 print("Hello")
2 print("World")
Execution result:
1 Hello
2 World
If you look closely you can find that, unlike other languages where a specific terminator is required to end each line of the statement, you simply need to press ENTER to end a line in MicroPython.