Last answered:

07 Nov 2022

Posted on:

12 Oct 2022

0

type(remainder) = tuple

Can someone explain why the type of this variable is tuple? What we want when using 'remainder is to have space for more input. But doesn't that contradict the tuple definiton?

2 answers ( 0 marked as helpful)
Instructor
Posted on:

14 Oct 2022

0

Hey Petko,

Thank you for reaching out!

Please refer to the definition of a tuple in the Python documentation. Hope this clears any confusion!

Kind regards,
365 Hristina

Posted on:

07 Nov 2022

1

When the calc_mean function is called, it may receive a variable number of arguments, and all but the first will be put in a tuple. So the size of the tuple depends on the number of arguments, which may vary. But for each function call, the arguments don't change between the call and the resolution of the function. This way, the function may be used with a variable number of arguments, but once the arguments are given they don't need to be mutable.

Submit an answer