# Lesson 6 Advanced Functions and G
# Lesson 6 Advanced Functions and G
# 1. Lambda Functions
print("\n--- Lambda Functions ---")
square = lambda x: x ** 2
print("Square of 5:", square(5))
# 2. Decorators
print("\n--- Decorators ---")
def decorator_function(func):
def wrapper():
print("Before the function call.")
func()
print("After the function call.")
return wrapper
@decorator_function
def say_hello():
print("Hello, world!")
say_hello()
# 3. Generators
print("\n--- Generators ---")
def simple_generator():
yield 1
yield 2
yield 3
gen = simple_generator()
print("First value:", next(gen))
print("Second value:", next(gen))
print("Third value:", next(gen))
print("Fibonacci sequence:")
for num in fibonacci(5):
print(num)
# End of Lesson 6