Oct () function in python
oct() function in Python: oct() function is an important function in Python . It transforms any data type into the octal form. If anyone wants to convert any data from any format to octal form then it can be done easily with the help of oct() function. Format:- oct(data), data is in int format. Parameters:- inside the oct function we have to only pass the integer data. Diagrammatic representation of oct function:- Implementation of oct function in Python Decimal to octal:- #decimal to octal a= int ( input ()) b= oct ( a ) print ( "the number " + str ( a ) + " in octal form is " + str ( b )) Here, we take a decimal number as input and print that number in the octal form. Binary to octal:- # Binary to octal c= int ( input () , 2 ) d= oct ( c ) print ( "the number " + str ( c ) + " in octal form is " + str ( d )) Here, we take a binary number as input and print that number in the octal form. Hexadecimal to octal:- #Hexadecimal to octal e= i