To create a Python function you need to write the word def followed by an space and the name of your function with a parenthesis, in the parenthesis you should write a letter for as many arguments you want the function to have, after the right parenthesis you put ‘:’. See examples following.
To define a function without argument you write:
def mensaje():
print (“Este es el mensaje contenido por la función”)
To define a function with one arguments, you write:
def mostrar(a):
print(a)
To define a function with two arguments, you write:
def sum(a,b)
print (a+b)
and so on!
Creating Python functions. Mastery 12. by Ismael Lizárraga is licensed under a Creative Commons Attribution 4.0 International License.