Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

#decimal to binary

def decimal2binary(dec):
binaryString = ""
while dec > 0:
bins = dec % 2
dec = dec // 2
binaryString = str(bins) + binaryString
return binaryString
d = int(input("Enter the decimal: "))
print(decimal2binary(d))

h = int(input("Enter the decimal: "))


print(decimal2hexa(h))

You might also like