📌 Basic Syntax
To call a function in Python, use the function name followed by parentheses:
function_name()
- Arguments: Values passed to the function (e.g.,
add(2, 3)
). - Return Value: Use
return
to send data back from a function.
🧠 Example: Function with Arguments
def greet(name):
return f"Hello, {name}!"
print(greet("Alice")) # Output: Hello, Alice!
📚 Extend Your Knowledge
For deeper understanding of functions, check our Python Functions Basics tutorial.
⚠️ Common Errors
- Forgetting parentheses:
greet "Bob"
❌ - Mismatched arguments:
add(2, "3")
❌ - Using
print
instead ofreturn
❌