Writing functions in Python