Theory of Intelligence
11TH•Computer Science•Python Programming•Question 6

Solution

Explain how default parameters work in Python functions.

Solution

Functions can have default parameter values, which are used if no argument is provided during the function call.

PYTHON
def greet(name="Student"):
    return "Hello, " + name + "!"

print(greet())           # Output: Hello, Student!
print(greet("Umer"))     # Output: Hello, Umer!

If greet() is called with no argument, name takes the default value "Student". If an argument is given, that value is used instead.

Discuss theoretical concepts, mathematical formulas, and architectural foundations.

Supports inline code with `backticks`
No comments yet. Be the first to start the discussion!