input: Write a function to convert a number into binary format. If the number is 0, the function should return 0. The function should use a loop to convert the number into its binary representation.
  def convert_to_binary(num):
      if num == 0:
          return 0
      binary = ''
      while num != 0:
          remainder = num % 2
          binary = str(remainder) + binary
          num = num // 2
      return binary
  
  # test the function 
  print(convert_to_binary(0))  # 0
  print(convert_to_binary(10)) # 1010
  print(convert_to_binary(7))  # 111
output: def convert_to_binary(num):
      if num == 0:
          return 0
      binary = ''
      while num != 0:
          remainder = num % 2
          binary = str(remainder) + binary
          num = num // 2
      return binary