mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-06 10:31:29 +08:00
refactor: Move constants outside of variable scope (#7262)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com> Co-authored-by: Christian Clauss <cclauss@me.com>
This commit is contained in:
@ -1,5 +1,9 @@
|
||||
"""Convert a positive Decimal Number to Any Other Representation"""
|
||||
|
||||
from string import ascii_uppercase
|
||||
|
||||
ALPHABET_VALUES = {str(ord(c) - 55): c for c in ascii_uppercase}
|
||||
|
||||
|
||||
def decimal_to_any(num: int, base: int) -> str:
|
||||
"""
|
||||
@ -65,13 +69,6 @@ def decimal_to_any(num: int, base: int) -> str:
|
||||
raise ValueError("base must be >= 2")
|
||||
if base > 36:
|
||||
raise ValueError("base must be <= 36")
|
||||
# fmt: off
|
||||
ALPHABET_VALUES = {'10': 'A', '11': 'B', '12': 'C', '13': 'D', '14': 'E', '15': 'F', # noqa: N806, E501
|
||||
'16': 'G', '17': 'H', '18': 'I', '19': 'J', '20': 'K', '21': 'L',
|
||||
'22': 'M', '23': 'N', '24': 'O', '25': 'P', '26': 'Q', '27': 'R',
|
||||
'28': 'S', '29': 'T', '30': 'U', '31': 'V', '32': 'W', '33': 'X',
|
||||
'34': 'Y', '35': 'Z'}
|
||||
# fmt: on
|
||||
new_value = ""
|
||||
mod = 0
|
||||
div = 0
|
||||
|
Reference in New Issue
Block a user