StepsEasy
Python Functions - Example
Run
Reset
Destroy & Close
← Back to lesson
Code Editor
python
# Basic function def greet(name, greeting="Hello"): return f"{greeting}, {name}!" # Multiple return values def get_stats(numbers): return min(numbers), max(numbers), sum(numbers)/len(numbers) # Lambda function square = lambda x: x ** 2 print(greet("Alice")) # Hello, Alice! print(greet("Bob", "Hi")) # Hi, Bob! print(get_stats([1, 2, 3, 4, 5])) # (1, 5, 3.0) print(square(5)) # 25
Result
Click "Run" to execute the code...
Loading runtime...
Ready
PYTHON | In-Browser Execution