#convert a positive integer to a binary #string. The input parameter is assumed #to be a positive integer, the return #value is the binary string. This #illustrates the while statement. def convert_pos_to_binary(n): bin="" while n!=0: nextbit=n%2 n=n/2 bin=str(nextbit)+bin return bin #convert an arbitrary integer to binary def convert_to_binary(n): if n>0: return convert_pos_to_binary(n) elif n==0: return '0' elif n<0: return "-"+convert_pos_to_binary(-n)