|
1 | 1 | # Instructions
|
2 | 2 |
|
3 | 3 | In this exercise, you are going to create a helpful program so that you don't have to remember the values of the bands.
|
4 |
| -The program will take 1, 4, or 5 colors as input, and outputs the correct value, in ohms. |
| 4 | +The program will take 1, 4, or 5 colors as input and output the correct value in ohms. |
5 | 5 | The color bands are encoded as follows:
|
6 | 6 |
|
7 |
| -- Black: 0 |
8 |
| -- Brown: 1 |
9 |
| -- Red: 2 |
10 |
| -- Orange: 3 |
11 |
| -- Yellow: 4 |
12 |
| -- Green: 5 |
13 |
| -- Blue: 6 |
14 |
| -- Violet: 7 |
15 |
| -- Grey: 8 |
16 |
| -- White: 9 |
17 |
| - |
18 |
| -In `resistor-color trio` you decoded the first three colors. |
| 7 | +- black: 0 |
| 8 | +- brown: 1 |
| 9 | +- red: 2 |
| 10 | +- orange: 3 |
| 11 | +- yellow: 4 |
| 12 | +- green: 5 |
| 13 | +- blue: 6 |
| 14 | +- violet: 7 |
| 15 | +- grey: 8 |
| 16 | +- white: 9 |
| 17 | + |
| 18 | +In [`Resistor Color Trio`][resistor-color-trio-exercise] you decoded the first three color bands. |
19 | 19 | For instance: orange-orange-brown translated to the main value `330`.
|
20 | 20 | In this exercise you will need to add _tolerance_ to the mix.
|
21 | 21 | Tolerance is the maximum amount that a value can be above or below the main value.
|
22 |
| -For example, if the last band is green, the maximum tolerance will be ±0.5%. |
| 22 | +For example, if the last band is green, the maximum tolerance will be `±0.5%`. |
23 | 23 |
|
24 | 24 | The tolerance band will have one of these values:
|
25 | 25 |
|
26 |
| -- Grey - 0.05% |
27 |
| -- Violet - 0.1% |
28 |
| -- Blue - 0.25% |
29 |
| -- Green - 0.5% |
30 |
| -- Brown - 1% |
31 |
| -- Red - 2% |
32 |
| -- Gold - 5% |
33 |
| -- Silver - 10% |
| 26 | +- grey - 0.05% |
| 27 | +- violet - 0.1% |
| 28 | +- blue - 0.25% |
| 29 | +- green - 0.5% |
| 30 | +- brown - 1% |
| 31 | +- red - 2% |
| 32 | +- gold - 5% |
| 33 | +- silver - 10% |
34 | 34 |
|
35 | 35 | The four-band resistor is built up like this:
|
36 | 36 |
|
37 | 37 | | Band_1 | Band_2 | Band_3 | band_4 |
|
38 | 38 | | ------- | ------- | ---------- | --------- |
|
39 | 39 | | Value_1 | Value_2 | Multiplier | Tolerance |
|
40 | 40 |
|
41 |
| -Meaning |
| 41 | +Examples: |
42 | 42 |
|
43 |
| -- orange-orange-brown-green would be 330 ohms with a ±0.5% tolerance. |
44 |
| -- orange-orange-red-grey would be 3300 ohms with ±0.05% tolerance. |
| 43 | +- orange-orange-brown-green would be `330` ohms with a `±0.5%` tolerance. |
| 44 | +- orange-orange-red-grey would be `3300` ohms with `±0.05%` tolerance. |
45 | 45 |
|
46 | 46 | The difference between a four and five-band resistor is that the five-band resistor has an extra band to indicate a more precise value.
|
47 | 47 |
|
48 | 48 | | Band_1 | Band_2 | Band_3 | Band_4 | band_5 |
|
49 | 49 | | ------- | ------- | ------- | ---------- | --------- |
|
50 | 50 | | Value_1 | Value_2 | Value_3 | Multiplier | Tolerance |
|
51 | 51 |
|
52 |
| -Meaning |
| 52 | +Examples: |
53 | 53 |
|
54 |
| -- orange-orange-orange-black-green would be 333 ohms with a ±0.5% tolerance. |
55 |
| -- orange-red-orange-blue-violet would be 323M ohms with a ±0.10 tolerance. |
| 54 | +- orange-orange-orange-black-green would be `333` ohms with a `±0.5%` tolerance. |
| 55 | +- orange-red-orange-blue-violet would be `323M` ohms with a `±0.10` tolerance. |
56 | 56 |
|
57 | 57 | There are also one band resistors.
|
58 | 58 | One band resistors only have the color black with a value of 0.
|
59 | 59 |
|
60 |
| -This exercise is about translating the resistor band colors into a label: |
| 60 | + |
| 61 | +Your program should translate an input `list` of resistor band colors into a label: |
61 | 62 |
|
62 | 63 | "... ohms ...%"
|
63 | 64 |
|
64 |
| -So an input of "orange", "orange", "black", "green" should return: |
| 65 | +So an input `list` of `["orange", "orange", "black", "green"]` should return: |
65 | 66 |
|
66 | 67 | "33 ohms ±0.5%"
|
67 | 68 |
|
68 | 69 | When there are more than a thousand ohms, we say "kiloohms".
|
69 | 70 | That's similar to saying "kilometer" for 1000 meters, and "kilograms" for 1000 grams.
|
70 | 71 |
|
71 |
| -So an input of "orange", "orange", "orange", "grey" should return: |
| 72 | +So an input `list` of `["orange", "orange", "orange", "grey"]` should return: |
72 | 73 |
|
73 | 74 | "33 kiloohms ±0.05%"
|
74 | 75 |
|
75 | 76 | When there are more than a million ohms, we say "megaohms".
|
76 | 77 |
|
77 |
| -So an input of "orange", "orange", "blue", "red" should return: |
| 78 | +So an input `list` of `["orange", "orange", "blue", "red"]` should return: |
78 | 79 |
|
79 | 80 | "33 megaohms ±2%"
|
| 81 | + |
| 82 | +[resistor-color-trio-exercise]: https://exercism.org/tracks/python/exercises/resistor-color-trio |
0 commit comments