PYTHON: Functions
Learn Functions in PYTHON with practical examples.
PYTHON — Functions
Overview
Functions group reusable code and accept parameters.
What you'll learn
- def
- parameters
- return
- default values
Syntax
def add(a,b): return a+b
Example
def greet(name="Guest"):
return f"Hello {name}"
print(greet("Ali"))
print(greet())
Notes
- Keep functions small.
- Return values instead of printing when possible.
Try: Open the Playground: /en/playground/python