Member-only story
Python Functions For Everyone (Well Explained)
This post is a part of my Python 101 series for total beginners (read here the previous post about Python Loops).
Let’s talk about functions…
Functions are nothing more than lines of code that you give a certain name so that you can call them later when you need them. This way, you can organize your code better so that the code is easier to read and understand.
When you create a function, you must define its name and the possible parameters that the function takes. Let’s immediately write a very simple function.
Click here to run this code — press the green “Run” button once there
def greetings(): # Defines a new function
print("This is my first function!") greetings() # Calls the functionWe defined our function by using the def keyword followed by the function name and the brackets (). In the body of the function, we have the line that prints This is my first function!.






