2023-08-11 17:11:58 +05:30
|
|
|
def octal_to_binary(octal_number):
|
|
|
|
"""
|
|
|
|
/**
|
|
|
|
* Converts any Octal Number to a Binary Number
|
|
|
|
*
|
|
|
|
* @author Bama Charan Chhandogi
|
|
|
|
*/
|
|
|
|
Convert an octal number to binary.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
octal_number (str): The octal number as a string.
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
str: The binary representation of the octal number.
|
|
|
|
|
|
|
|
Examples:
|
|
|
|
>>> octal_to_binary("34")
|
|
|
|
'0b11100'
|
|
|
|
>>> octal_to_binary("777")
|
|
|
|
'0b111111111'
|
|
|
|
"""
|
|
|
|
decimal_number = int(octal_number, 8)
|
|
|
|
binary_number = bin(decimal_number)
|
|
|
|
return binary_number
|
|
|
|
|
2023-08-11 11:44:02 +00:00
|
|
|
|
2023-08-11 17:11:58 +05:30
|
|
|
if __name__ == "__main__":
|
|
|
|
import doctest
|
2023-08-11 11:44:02 +00:00
|
|
|
|
2023-08-11 17:11:58 +05:30
|
|
|
doctest.testmod()
|