Python program to convert a decimal number to octal number using function

0
15
""" Python program to convert a decimal number to octal number without using 
 direct functions for standard base conversions like oct()"""

def dec_to_octal(n):    # function to convert decimal to octal 
           octal_num = [0] * 100;   # create array to store octal number 
           i = 0; # counter for octal 
           while (n != 0): 
                   octal_num[i] = n % 8;   # storing remainder
                   n = int(n / 8); 
                   i += 1; 
           for j in range(i - 1, -1, -1): 
                   print(octal_num[j], end = ""); 
#_____main_____ 
num=int(input("Please enter a number: ")) 
dec_to_octal(num) 

     Output 1:
             Please enter a number: 123
             173
     Output 2:
             Please enter a number: 24
             30

इन्हें भी देखें।

Python Programs के लिये यहाँ click करें।

 

 

 

Python program to convert a decimal number to octal number using function write a program to convert a decimal number to octal number using function in python write a program to convert a decimal number to octal number using function write a python program to convert a decimal number to octal number using function Python program to convert a decimal number to octal number program to convert a decimal number to octal number program to convert a decimal number to octal number using function in python convert a decimal number to octal number using function convert a decimal number to octal number in python convert a decimal number to octal number program to convert decimal number to octal number write a python program to convert a decimal number to octal number python program to convert decimal number to octal number write a program to convert a decimal number to a octal number in python program to convert octal number to decimal number in python python program to convert decimal number into octal number write a program to convert decimal number into octal number python program to convert decimal number to octal python program to convert decimal to octal number write a python program to convert decimal number to octal number program to convert decimal to octal write a program to convert decimal to octal write a python program to convert decimal to octal number system how to convert decimal number to octal number how to convert decimal number to octal number in python how to convert a decimal number to octal

LEAVE A REPLY

Please enter your comment!
Please enter your name here