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.
main.py# 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:
main.py# 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: home page
Next: MicroPython Tutorial Exercise 2: functions