Deloitte | COGNIZANT | IBM | CAPGEMINI
def findResistorColorBands(power, current):
d = {
0: 'BLK', 1: 'BWN', 2: 'RED', 3: 'ONG', 4: 'YLW',
5: 'GRN', 6: 'BLU', 7: 'VLT', 8: 'GRY', 9: 'WHT'
}
if power <= 0 or current <= 0 or current > power:
print("Invalid input")
return ""
res = power // current
res_str = str(res)
if len(res_str) < 2:
print("Invalid input")
return ""
dig = res_str[:2]
mul = len(res_str) - 2
try:
b1 = d[int(dig[0])]
b2 = d[int(dig[1])]
b3 = d[mul]
print(f"{b1} {b2} {b3}")
return ""
except:
print("Invalid input")
return ""
#findResistanceColorBands✅✅✅
632 ·