read.cash Log in
@MyHero

Program 101: Decimal to Binary, Octal and Hexadecimal using Python This program convert decimal to binary, octal and hexadecimal Notes: - I'm using the built functions bin(), oct() and hex() for this program - Using these functions it will display with 0b for bin(), 0o for oct() and 0x for hex(). I use the splitting method to remove it. - https://blog.finxter.com/introduction-to-slicing-in-python/ Program Link: https://onlinegdb.com/-Qp1BOkO4 Code: # Convert Decimal to Binary, Octal and Hexadecimal using Python dec = int(input("Enter a number: ")) print("\n----- Result -----") print("Binary:", bin(dec)[2:]) print("Octal:", oct(dec)[2:]) print("Hexadecimal:", hex(dec)[2:].upper())

No comments yet

Log in to join in Reading is open to everyone. Replying needs an account.