Number to Binary converter.
Welcome number to binary convert.
But condition is if you type any number space and decimal does not include.
def convert_to_binary(num):
"""Converts a only int number to its binary equivalent.
Returns:
The binary representation of the number as a string.
"""
binary = ""
while num > 0:
remainder = num % 2
binary = str(remainder) + binary
num //= 2
return binary
# Convert any number to binary
i= int(input("Enter the value = ")) #It change in decimail so change the 'int' to 'float'
binary_value = convert_to_binary(i)
print( i,f"in binary: {binary_value}")
Comments