!!! main.py
This is __Exercise 1__ of the [Micro Python Tutorial].
The file {{main.py}} is special in MicroPython, only in the sense that when you power-on the device and/or press the reset button, the main.py file is executed.
%%filename main.py %%
%%python
\\# this is a comment
print('hello world.')
print("hello again.")
%%
There is a structure in Python called a {{try-except-finally}} __block__, which is ideal for a main.py file:
%%filename main.py %%
%%python
\\# this is a comment
try:
print('hello world.')
^^^^ 🠈 remember to indent the insides of your blocks by 4 characters!
except Exception as ex:
print('an error occurred: {}'.format(ex))
finally:
print('complete.')
%%
----
__Previous:__ [MicroPython Tutorial Exercise 1|MicroPythonTutorialExercise01]: main.py \\
__Next:__ [MicroPython Tutorial Exercise 2|MicroPythonTutorialExercise02]: functions