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 averages on python 
Python :: spacy nlp load 
Python :: python numpy array delete multiple columns 
Python :: python iterate through dictionary 
Python :: python ascii code to string 
Python :: random id python 
Python :: python set intersection 
Python :: how to fill a list in python 
Python :: Django group by date from datetime field 
Python :: isidentifier method in python 
Python :: create bigram in python 
Python :: python dict sort by value 
Python :: how to find empty rows of a dataset in python 
Python :: when was python developed 
Python :: how to make a sigmoid function in python 
Python :: append one row to pandas dataframe 
Python :: how to print time python 
Python :: pep full form 
Python :: what does ^ do python 
Python :: python for loop even numbers 
Python :: pycairo 
Python :: python manage.py collectstatic --noinput 
Python :: how to set breakpoint in python pdb 
Python :: df reset index 
Python :: remove element from list python 
Python :: genrate unique key in python 
Python :: failed to allocate bitmap 
Python :: pyautogui press enter 
Python :: how to check if a cell is empty in openpyxl 
Python :: python adding digits 
ADD CONTENT
Topic
Content
Source link
Name
4+3 =