mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-02-25 18:38:39 +00:00
Compare commits
2 Commits
9e75dd770e
...
920fcc4559
Author | SHA1 | Date | |
---|---|---|---|
|
920fcc4559 | ||
|
8906c9d676 |
@ -2,17 +2,14 @@
|
|||||||
* 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
|
||||||
>>> oct_to_decimal("Av")
|
>>> oct_to_decimal("Av")
|
||||||
@ -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")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user