Function basics

This Python recipe includes:

  • Define a function
  • Execute a function

Define and execute a function

# Define a function that adds two numbers
def sum(input1, input2):
    return input1 + input2

# Call/use the sum function
sum1 = sum(210, 30)
print('The sum of 210 and 30 is %d' % sum1)
The sum of 210 and 30 is 240

Leave a Reply

Your email address will not be published. Required fields are marked *