Binary number
-It is a number which expressed in the base-2 numeral system,
-Binary numbers is 0 or 1
Octal number
- A number which expressed in the base-8 numeral system.
- Octal number range is 0 to 7
Conversion of binary to octal-
Example -
Binary number is 101010
Its octal equivalent is 52
Binary number is 1111
Its octal equivalent is 17
program -
print("Enter Binary number")
n=int(input())
def func(n):
s=0
i=0
while(n):
t=n%10
s=s+t*(2**i)
n=int(n/10)
i=i+1
return s
s=0
while(n>0):
t=n%1000
s=s*10+func(t)
n=int(n/1000)
s=str(s)
s=s[::-1]
print("Octal equivalent is - "+str(s))
Enter Binary number
101010
Octal equivalent is - 52
Enter Binary number
1111111
Octal equivalent is - 177