Junior — Middle
Can you explain what is meant by the concept of a function in programming?
sobes.tech AI
Answer from AI
A function in programming is a named block of code that performs a specific task and can accept input data (arguments), as well as return a result. Functions help structure the program, reuse code, and improve readability.
Example of a function in Python:
def greet(name):
return f"Hello, {name}!"
print(greet("Anna")) # Outputs: Hello, Anna!