Functions: Difference between revisions
From Jedisaber Wiki
Created page with "A function is a block of code that only runs when it is called. You can pass data to a function. A function can return data as a result. You can create a function by defining it: <code> def my_function(): print("Hello from a function") </code> ... and call it thusly: <code> my_function() </code>" |
No edit summary |
||
| (2 intermediate revisions by the same user not shown) | |||
| Line 7: | Line 7: | ||
You can create a function by defining it: | You can create a function by defining it: | ||
< | <pre> | ||
def my_function(): | def my_function(): | ||
print("Hello from a function") | print("Hello from a function") | ||
</ | </pre> | ||
... and call it thusly: | ... and call it thusly: | ||
<code> | <code>my_function()</code> | ||
my_function() | |||
</code> | |||
=== References === | |||
https://www.w3schools.com/python/python_functions.asp | |||
Latest revision as of 00:38, 27 June 2025
A function is a block of code that only runs when it is called.
You can pass data to a function.
A function can return data as a result.
You can create a function by defining it:
def my_function():
print("Hello from a function")
... and call it thusly:
my_function()
