mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-02-25 10:28:39 +00:00
added documention and some test cases
This commit is contained in:
parent
3040f99707
commit
fa33d5cc63
@ -1,7 +1,31 @@
|
|||||||
|
"""
|
||||||
|
* Author: Bama Charan Chhandogi (https://github.com/BamaCharanChhandogi)
|
||||||
|
* Description: Convert a Octal number to Binary.
|
||||||
|
|
||||||
|
reference for better understand
|
||||||
|
|
||||||
|
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 = ""
|
binary_number = ""
|
||||||
octal_digits = "01234567"
|
octal_digits = "01234567"
|
||||||
|
|
||||||
|
"""
|
||||||
|
ValueError: String to the function
|
||||||
|
>>> oct_to_decimal("Av")
|
||||||
|
Traceback (most recent call last):
|
||||||
|
...
|
||||||
|
ValueError: Non-octal value was passed to the function
|
||||||
|
>>> oct_to_decimal("90")
|
||||||
|
Traceback (most recent call last):
|
||||||
|
...
|
||||||
|
ValueError: octal value was passed to the function
|
||||||
|
>>> oct_to_decimal("17")
|
||||||
|
001111
|
||||||
|
>>> oct_to_decimal("7")
|
||||||
|
111
|
||||||
|
"""
|
||||||
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")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user