OneBite.Dev - Coding blog in a bite size

declare a function with multiple parameter in python

Code snippet on how to declare a function with multiple parameter in python

def add_nums(x, y):
  return x + y

This code declares a function called “add_nums” that takes two parameters, x and y. The function will return the sum of x and y, so it adds them together. The keyword “def” lets Python know that you are defining a function, then the function’s name (“add_nums”) is given, followed by the parameters (x and y) within brackets. The body of the function comes after the colon and is indented, which in this case just has the return statement, which tells the function to give back the sum of the two parameters when called.

python