Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to call the function with the correct positional argument.
Python
def greet(name): return f"Hello, {name}!" message = greet([1]) print(message)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
๐ก Hint
Common Mistakes
Passing the function name instead of a string.
Passing a variable that is not defined.
โ Incorrect
The function greet expects a string argument for the name. Passing "Alice" correctly provides the name.
2fill in blank
mediumComplete the function call using a keyword argument.
Python
def describe_pet(pet_name, animal_type='dog'): return f"I have a {animal_type} named {pet_name}." info = describe_pet([1]) print(info)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
๐ก Hint
Common Mistakes
Passing only a string without specifying the parameter name.
Using the wrong parameter name.
โ Incorrect
Using the keyword argument pet_name='Buddy' correctly assigns the pet_name parameter.
3fill in blank
hardFix the error in the function call by placing arguments in the correct order.
Python
def make_shirt(size, message): return f"Shirt size: {size}, message: {message}" result = make_shirt([1]) print(result)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
๐ก Hint
Common Mistakes
Swapping the order of positional arguments.
Mixing positional and keyword arguments incorrectly.
โ Incorrect
Positional arguments must be in the order defined: size first, then message.
4fill in blank
hardFill both blanks to create a function call with one positional and one keyword argument.
Python
def order_drink(size, flavor): return f"Order: {size} {flavor} drink" order = order_drink([1], [2]) print(order)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
๐ก Hint
Common Mistakes
Using keyword argument before positional argument.
Not specifying the keyword argument name.
โ Incorrect
The first argument is positional (size), the second is keyword (flavor).
5fill in blank
hardFill all three blanks to call the function with one positional and two keyword arguments in correct order.
Python
def book_flight(destination, seat_class='Economy', meal='Standard'): return f"Flight to {destination}, Class: {seat_class}, Meal: {meal}" confirmation = book_flight([1], [2], [3]) print(confirmation)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
๐ก Hint
Common Mistakes
Placing keyword arguments before positional arguments.
Not using parameter names for keyword arguments.
โ Incorrect
The first argument is positional (destination), followed by keyword arguments seat_class and meal.