Functions#

This is Exercise 2 of the Micro Python Tutorial.

We can define functions in Python. Functions are defined globally, within the file/module as they begin in column 0.

main.py

# we define a function called "display_message" def display_message(message): print(message) raise Exception('we did something wrong.')

try: display_message('hello world.') except Exception as e: print('an error occurred: {}'.format(e)) finally: print('complete.')


Previous: MicroPython Tutorial Exercise 1: main.py
Next: MicroPython Tutorial Exercise 3: classes