{"id":19164,"date":"2021-08-29T15:13:53","date_gmt":"2021-08-29T09:43:53","guid":{"rendered":"https:\/\/python-programs.com\/?p=19164"},"modified":"2021-11-22T18:37:08","modified_gmt":"2021-11-22T13:07:08","slug":"python-program-to-convert-binary-to-octal-using-while-loop","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-to-convert-binary-to-octal-using-while-loop\/","title":{"rendered":"Python Program to Convert Binary to Octal using While Loop"},"content":{"rendered":"

In the previous article, we have discussed Python Program to Convert Octal to Decimal using While Loop<\/a>
\nGiven a binary number and the task is to get the respective octal number using the while loop.<\/p>\n

Examples:<\/strong><\/p>\n

Example1:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given Binary Number = 1010<\/pre>\n

Output:<\/strong><\/p>\n

The Octal value of the given binary number { 1010 } is: \r\n12<\/pre>\n

Example2:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given Binary Number = 1101<\/pre>\n

Output:<\/strong><\/p>\n

The Octal value of the given binary number { 1101 } is: \r\n15<\/pre>\n

Program to Convert Binary to Octal using While Loop in Python<\/h2>\n

Below are the ways to convert the given binary number into octal :<\/p>\n