How can you specify a default value for a parameter in a function definition?
- By wrapping the parameter in square brackets []
- Using an asterisk (*)
- Using the '=' sign
- Using the 'default' keyword
To specify a default value for a parameter, you can use the '=' sign followed by the default value. For example, def func(param=10):.
Loading...
Related Quiz
- You are implementing a function to calculate the factorial of a number. Which Python built-in data type would be most suitable to store the result for very large numbers?
- A decorator in Python is a design pattern used to add new functionality to an object without altering its ____.
- If you want to throw an error when a certain condition is met in your code, you can use the _______ keyword.
- In a for loop, what does the range(3, 8, 2) function return?
- How does a metaclass differ from a class in Python?