<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def parity(num: int) -> int: """Return the parity of a non-negative integer. For example, here are the parities of the first ten integers: [0, 1, 1, 0, 1, 0, 0, 1, 1, 0] This function is undefined for negative integers: Traceback (most recent call last):
 ValueError: expected num >= 0 """

    if num < 0:
        raise ValueError("expected num >= 0")
    par = 0
    while num:
        par ^= (num & 1)
        num >>= 1
    return par