Sobes.tech
Junior — Middle

What keyword is used in Python to define a function?

sobes.tech AI

Answer from AI

In Python, the keyword def is used to define a function.

Example of defining a function:

def greet(name):
    return f"Hello, {name}!"

print(greet("World"))  # Outputs: Hello, World!