Chrome Extension

Create a function in python

def function_name():
    print("Hello this is a function")

#To call the above function use
function_name()
Best JSON Validator, JSON Tree Viewer, JSON Beautifier at same place. Check how cool is the tool
Output
Hello this is a function

You can create a function in python by using the 'def' keyword before the function name. The above code snippet function will print - Hello this is a function when called. You can also use the function to return some values or data when called.

Was this helpful?
1 Comments

You can also pass parameters to a function and use them inside the function code block.

Passing parameters to function

def hello(username):
    print("Hello," + username)


hello("John")

The code will output 'Hello John' as we called the function by passing 'John' as 'username' parameter value.

Join Devsheet Ask a Question