Day 2 : Function Arguments & Return Values
Today I learned how to make functions more powerful by passing values into a function and returning values back from a function.
This helps make functions flexible, reusable, and cleaner.
What I Learned Today
- A function can accept parameters
- You can pass arguments when calling the function
- A function can send back a value using
return - Returned values can be stored in variables
Example Code From Day 2
# Day 2 - Function Parameters and Return Values
# This function takes a name as input and returns a greeting message
def greet(name):
return f"Hello, {name}!"
# Calling the function
message = greet("Rekha")
print(message)
Output
Hello, Rekha!
Summary
Today I learned how functions become more useful when they accept parameters and return values:
- Functions with parameters are more flexible
- The
returnstatement gives back a result - Returned values can be stored in variables
This helps make Python code cleaner and more powerful.