mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-02-25 10:28:39 +00:00
fixes documention
This commit is contained in:
parent
9e75dd770e
commit
8906c9d676
@ -2,16 +2,13 @@
|
|||||||
* Author: Bama Charan Chhandogi (https://github.com/BamaCharanChhandogi)
|
* Author: Bama Charan Chhandogi (https://github.com/BamaCharanChhandogi)
|
||||||
* Description: Convert a Octal number to Binary.
|
* Description: Convert a Octal number to Binary.
|
||||||
|
|
||||||
reference for better understand
|
References for better understanding:
|
||||||
|
https://en.wikipedia.org/wiki/Binary_number
|
||||||
|
https://en.wikipedia.org/wiki/Octal
|
||||||
|
|
||||||
URL: https://en.wikipedia.org/wiki/Binary_number
|
|
||||||
URL: https://en.wikipedia.org/wiki/Octal
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
def octal_to_binary(octal_number: str) -> str:
|
def octal_to_binary(octal_number: str) -> str:
|
||||||
binary_number = ""
|
|
||||||
octal_digits = "01234567"
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
ValueError: String to the function
|
ValueError: String to the function
|
||||||
@ -35,6 +32,8 @@ def octal_to_binary(octal_number: str) -> str:
|
|||||||
>>> oct_to_decimal("7")
|
>>> oct_to_decimal("7")
|
||||||
111
|
111
|
||||||
"""
|
"""
|
||||||
|
binary_number = ""
|
||||||
|
octal_digits = "01234567"
|
||||||
for digit in octal_number:
|
for digit in octal_number:
|
||||||
if digit not in octal_digits:
|
if digit not in octal_digits:
|
||||||
raise ValueError("Invalid octal digit")
|
raise ValueError("Invalid octal digit")
|
||||||
@ -52,4 +51,4 @@ def octal_to_binary(octal_number: str) -> str:
|
|||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
import doctest
|
import doctest
|
||||||
|
|
||||||
doctest.testmod()
|
doctest.testmod()
|
Loading…
x
Reference in New Issue
Block a user