hello world funciton in python

Here's a simple Python function that prints 'Hello, World!' to the console when called:

main.py
def my_function():
    print('Hello, World!')

my_function() # call the function
81 chars
5 lines

In this example, my_function is defined using the def keyword, which specifies the name of the function and any arguments it may take (in this case, no arguments are specified). The print statement then outputs the string 'Hello, World!' to the console. Finally, the function is called using the function name followed by parentheses (my_function()), which executes the code within the function block. When this script is run, the output will be:

main.py
Hello, World!
14 chars
2 lines

gistlibby LogSnag