Ask Question
23 April, 17:52

Octal numbers have a base of eight and the digits 0-7. Write the scripts octalToDecimal. py and decimalToOctal. py, which convert numbers between the octal and decimal representations of integers. These scripts use algorithms that are similar to those of the binaryToDecimal and decimalToBinary scripts developed in the Section: Strings and Number Systems.

+5
Answers (1)
  1. 23 April, 18:21
    0
    See explaination

    Explanation:

    #input

    o_t_n=int (input ('Enter a string of octal digits: '))

    #required variables

    i = 1

    dc = 0

    #loop for conversion

    while (o_t_n! = 0):

    #to find remainder

    rmd = o_t_n % 10

    o_t_n / / = 10

    dc + = rmd * i

    i * = 8

    #print the results

    print ('The integer value is ', dc)

    # decimalToOctal. py

    #input

    d_c_n=int (input ('Enter a decimal integer: '))

    print ("Quotient Remainder Octal")

    #required variables

    i = 1

    o_c_n = 0

    num=""

    #loop for conversion

    while (d_c_n! = 0):

    #to find remainder

    rm = d_c_n % 8

    d_c_n / / = 8

    o_c_n = o_c_n + rm * i

    i * = 10

    num = str (rm) + num

    print ("%5d%8d%12s" % (d_c_n, rm, num))

    #print the results

    print ('The octal representation is ', o_c_n)
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Octal numbers have a base of eight and the digits 0-7. Write the scripts octalToDecimal. py and decimalToOctal. py, which convert numbers ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers