Here's a simple Python function that prints 'Hello, World!' to the console when called:
main.py81 chars5 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.py14 chars2 lines
gistlibby LogSnag