Skip to content
Foxipa
Code Completion 4 Challenges

Complete the Python function parameters code

Practice positional-only, keyword-only, *args, and **kwargs parameters.

Intermediate ~8 min read

Challenge 1

Make amount positional-only.

python Your answer
def price(amount,):
    return amount * 2

print(price(5))

Press Ctrl⌘Enter to check your answer

Challenge 2

Make timeout keyword-only while keeping host positional.

python Your answer
def connect(host,):
    return host, timeout

print(connect("example.com", timeout=5))

Press Ctrl⌘Enter to check your answer

Challenge 3

Collect all positional values in numbers.

python Your answer
def total():
    return sum(numbers)

print(total(2, 4, 6))

Press Ctrl⌘Enter to check your answer

Challenge 4

Collect all extra keyword arguments in details.

python Your answer
def describe():
    return details

print(describe(language="Python", level="core"))

Press Ctrl⌘Enter to check your answer