Practice question from Control Flow & Functions

What does this function return? A. <class 'int'> B. <class 'list'> C. <class 'tuple'> D. <class 'dict'> E. <class 'str'>

def calculate(a, b):
    sum_val = a + b
    product = a * b
    return sum_val, product

result = calculate(3, 4)
print(type(result))

Answer

C

Explanation

When you return multiple values separated by commas, Python automatically packages them into a tuple. So 'return sum_val, product' returns a tuple containing (7, 12), making the type a tuple.

More questions from Python Programming