Skip to main content

Posts

Showing posts with the label integer

Python - Convert Decimal Number to Binary

🐍  Using Python, create a converter that converts decimal base number into binary base number. Solution def convertDecimalToBinary(decinum):          binum = ''     rem = decinum          while rem>0:         binum = binum + str(rem%2)         rem = rem//2          return binum[::-1] if __name__=='__main__':          decinum = int(input("Enter a decimal number: "))     print(f'The binary equivalent of {decinum} is {convertDecimalToBinary(decinum)}')