진법 변환
·
Python 활용하기
N진수에 N은 등장하지 않는다! 1. 2/8/16진법 -> 10진법 print(int('0b1010', 2)) # 10 print(int('0o')) 2. 10진법 -> 2/8/16진법 b = bin(10) # '0b1010' o = oct(18) # '0o22' h = hex(33) # '0x21' 3. 10진법 -> N진법 3-1. 재귀함수 import string def convert_notation(number:int, base:int)->int: base_num = string.digits + string.ascii_uppercase q, r = divmod(number, base) if q: return convert_notation(q, base) + number[r] else: number..