Resistance Label
Three resistor color bands can be turned into a readable resistance label. The function label receives a list colors: the first two colors give the significant digits, and the third color gives the multiplier as a power of 10. Return a string using ohms, or kiloohms when the value is best written in kiloohms.
Примеры
Ввод
["orange", "orange", "black"]Вывод
"33 ohms"Ввод
["blue", "grey", "brown"]Вывод
"680 ohms"Ввод
["red", "black", "red"]Вывод
"2 kiloohms"Нужно реализовать
def label(colors: list[str]) -> str:
Теги
listsstrings
Přihlaste se, abyste viděli historii odevzdání
Přihlásit sePřihlaste se, abyste mohli použít AI mentora
Přihlásit seVisible tests
1
Input
["orange","orange","black"]Expected
"33 ohms"2
Input
["blue","grey","brown"]Expected
"680 ohms"3
Input
["red","black","red"]Expected
"2 kiloohms"4
Input
["green","brown","orange"]Expected
"51 kiloohms"5
Input
["black","black","black"]Expected
"0 ohms"6
Input
["black","red","red"]Expected
"200 ohms"Focus radio
Paused · SomaFM · Fluid