code: def randbelow(num: int) -> int:
      
      if not isinstance(num, int):
          raise TypeError('number must be an integer')
      if num <= 0:
          raise ValueError('number must be greater than zero')
      if num == 1:
          return 0
  
      # https://github.com/python/cpython/blob/3.6/Lib/random.py#L223
      nbits = num.bit_length()    # don't use (n-1) here because n can be 1
      randnum = random_randint(nbits)    # 0 <= randnum < 2**nbits
      while randnum >= num:
          randnum = random_randint(nbits)
      return randnum
docs: Return a random int in the range [0,num).
  
      Raises ValueError if num <= 0, and TypeError if it's not an integer.
  
      >>> randbelow(16)  #doctest:+SKIP
      13