Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

converting binary to octal in python

biNum = '1010'
print(oct(int(biNum, 2))[2:]) 
Comment

binary to octal in python

 ==== Convert binary to octal in Python =====
binaryNum = '11001100'  # input a binary

decimalNum = int(binaryNum, 2)  # base 2 to base 10
print(decimalNum, type(decimalNum))  # 204 <class 'int'>

octalNum = oct(decimalNum)[2:]  # base 10 to base 8
print(octalNum, type(octalNum))  # 314 <class 'str'>
Comment

PREVIOUS NEXT
Code Example
Python :: make sure it only has letters and numbers python 
Python :: get drive path python 
Python :: latest version of python 
Python :: Python create a new png file 
Python :: pca 
Python :: python merge dict 
Python :: math module in python 
Python :: Login script using Python and SQLite 
Python :: <IPython.core.display.HTML object 
Python :: how to plot stacked bar chart from grouped data pandas 
Python :: django update field after save 
Python :: permission denied when converting dataframe to csv 
Python :: how to convert a datatype to another 
Python :: isnotin python 
Python :: python get file line count 
Python :: Drop multiple columns with their index 
Python :: python string iterate 3 characters at a time 
Python :: math module sin() function in python 
Python :: create virtual environment python stack overflow 
Python :: seaborn distribution plot for all columns 
Python :: remove empty string from list python single line 
Python :: filter directory in python 
Python :: open pdfs using python 
Python :: if key in dictionary python 
Python :: palindrome words python 
Python :: ip address finder script python 
Python :: find index of element in array python 
Python :: print data type array 
Python :: open image in PILLOW 
Python :: how to use sin inverse and cos inverse in python 
ADD CONTENT
Topic
Content
Source link
Name
7+1 =