Skip to content

Commit 8d5244e

Browse files
authored
Add functions to retrieve color indices and calculate value
Implemented functions to get resistor color values and calculate total resistance.
1 parent bc67d58 commit 8d5244e

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed
Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,39 @@
1+
2+
dict = {
3+
"black": 0,
4+
"brown": 1,
5+
"red": 2,
6+
"orange": 3,
7+
"yellow": 4,
8+
"green": 5,
9+
"blue": 6,
10+
"violet": 7,
11+
"grey": 8,
12+
"white": 9
13+
}
14+
15+
16+
def get_color1_index(color1):
17+
if color1 in dict:
18+
for c in dict:
19+
s = dict[color1]
20+
return s
21+
else:
22+
return "The color doesn't exist."
23+
24+
def get_color2_index(color2):
25+
if color2 in dict:
26+
for c in dict:
27+
s = dict[color2]
28+
return s
29+
else:
30+
return "The color doesn't exist."
31+
132
def value(colors):
2-
pass
33+
color1 = colors[0]
34+
color2 = colors[1]
35+
ind1 = str(get_color1_index(color1))
36+
ind2 = str(get_color2_index(color2))
37+
ind = ind1 + ind2
38+
value = int(ind)
39+
return value

0 commit comments

Comments
 (0)