Complete the code to define a function with a default argument.
def greet(name=[1]): print(f"Hello, {name}!")
The default argument must be a string, so it needs quotes. "Guest" is correct.
Which value should be passed to greet() so it prints 'Hello, Guest!'?
def greet(name="Guest"): print(f"Hello, {name}!") result = greet([1])
Passing "Guest" explicitly produces the same output as calling with no arguments, since the default value is "Guest".
Fix the error in the function definition by completing the default argument correctly.
def multiply(x, y=[1]): return x * y
The default argument y should be a number, so 1 without quotes is correct.
Fill both blanks to create a function with two default arguments and call it with one argument.
def order(item, quantity=[1], price=[2]): total = quantity * price print(f"Order: {quantity} {item}(s) for ${total}") order("apple")
Quantity defaults to 1 and price to 0.5 to calculate total correctly.
Fill all three blanks to create a function with default arguments and call it with two arguments.
def describe_pet(name=[1], species=[2], age=[3]): print(f"{name} is a {age}-year-old {species}.") describe_pet("Buddy", "dog")
Default name is "Buddy" but overridden by argument, species default "dog", age default 3.