1 ==== Convert binary to octal in Python =====
2binaryNum = '11001100' # input a binary
3
4decimalNum = int(binaryNum, 2) # base 2 to base 10
5print(decimalNum, type(decimalNum)) # 204 <class 'int'>
6
7octalNum = oct(decimalNum)[2:] # base 10 to base 8
8print(octalNum, type(octalNum)) # 314 <class 'str'>