Dayrvia
Py

Python · Default arguments · Practice questions

Try 2 questions on Python · Default arguments, then read the explanations and review the related concepts.

Practice questions

Choose an answer and move to the next question. Grade the last one to see explanations and review links.

2 questions
Q1 What is x?
def put(n, bag=[]):
    bag.append(n)
    return len(bag)
put(4)
x = put(5)
Q2 What does a subsequent collect(2) return?
def collect(x, bag=None):
    if bag is None:
        bag = []
    bag.append(x)
    return bag
collect(1)
Original practice questions written for Dayrvia.