Python Function - Converts an Octal Number to its equivalent numbers in decimal, binary & hexadecimal

def Oct2Others(n):
    print()
    print("The Octal Number     :",n)
    numString=str(n)
    decNum=int(numString,8)
    print("Number in Decimal    :",decNum)
    print("Number in Binary     :",bin(decNum))
    print("Number in HexaDecimal:",hex(decNum))


num=int(input("Enter an Octal Number: "))
Oct2Others(num)




Output

Enter an Octal Number: 15

The Octal Number     : 15
Number in Decimal    : 13
Number in Binary     : 0b1101
Number in HexaDecimal: 0xd




No comments

Post your comments

Powered by Blogger.