New Base to Number
A string like FF can represent a regular number once you know its numeral system. Given a string text and a base from 2 to 16, convert the value from that base into a decimal integer. Return the resulting integer.
Примеры
Ввод
"101", 2Вывод
5Ввод
"0", 2Вывод
0Ввод
"FF", 16Вывод
255Нужно реализовать
def base_to_int(text: str, base: int) -> int:
Теги
math
Prihláste sa, aby ste videli históriu odoslaní
Prihlásiť saPrihláste sa, aby ste mohli používať AI mentora
Prihlásiť saVisible tests
1
Input
"101", 2Expected
52
Input
"0", 2Expected
03
Input
"FF", 16Expected
2554
Input
"1010", 2Expected
105
Input
"FF", -16Expected
-2256
Input
"1010", 10Expected
1010Focus radio
Paused · SomaFM · Fluid