What is the result of % in Python?

The % (modulo) operator yields the remainder from the division of the first argument by the second. The numeric arguments are first converted to a common type. A zero right argument raises the ZeroDivisionError exception. The arguments may be floating point numbers, e.g., 3.14%0.7 equals 0.34 (since 3.14 equals 4*0.7 + 0.34.) The modulo operator … Read more

What is the := operator?

In all languages that support an operator := it means assignment. In languages that support an operator :=, the = operator usually means an equality comparison. In languages where = means assignment, == is typically used for equality comparison. does := mean =? I can’t recall any languages where := means the same as =. In MySQL := and = are both used for assignment, however they are not interchangeable and selecting the correct one … Read more

What does ** (double star/asterisk) and * (star/asterisk) do for parameters?

The *args and **kwargs is a common idiom to allow arbitrary number of arguments to functions as described in the section more on defining functions in the Python documentation. The *args will give you all function parameters as a tuple: The **kwargs will give you all keyword arguments except for those corresponding to a formal parameter as a dictionary. Both idioms can be mixed with normal arguments to … Read more