Octal To Binary Conversion

    0

    0

    CrypticSai-08

    def convert(octal):
        i = 0
        decimal = 0
        while octal != 0:
            digit = octal % 10
            decimal += digit * pow(8, i)
            octal //= 10
            i += 1
        print("Decimal Value :", decimal)
        binary = 0
        rem = 0
        i = 1
        while decimal != 0:
            rem = decimal % 2
            decimal //= 2
            binary += rem * i
            i *= 10
        print("Binary Value :", binary)
    octal = int(input("Octal Value : "))
    convert(octal)
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Explore
    • Cookbooks
    • Playground
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.