Back to Developer Roadmap

Functions

src/data/roadmaps/python/content/[email protected]

4.0722 B
Original Source

Functions

In programming, a function is a reusable block of code that executes a certain functionality when it is called. Functions are integral parts of every programming language because they help make your code more modular and reusable. In Python, we define a function with the def keyword, then write the function identifier (name) followed by parentheses and a colon.

Example

def greet(name):
    print(f"Hello, {name}!")


greet("Roadmap.sh")

Visit the following resources to learn more: