material is a string indicating the material of the wire length is a floating value indicating the length of the wire in meters diameter is a floating value indicating the diameter of the wire in millimeters temperature is a floating value indicating the temperature at which the
(
material: str, length: float, section: float, temperature: float
)
| 1 | def resistance_calculator( |
| 2 | material: str, length: float, section: float, temperature: float |
| 3 | ): |
| 4 | """ |
| 5 | material is a string indicating the material of the wire |
| 6 | |
| 7 | length is a floating value indicating the length of the wire in meters |
| 8 | |
| 9 | diameter is a floating value indicating the diameter of the wire in millimeters |
| 10 | |
| 11 | temperature is a floating value indicating the temperature at which the wire is operating in °C |
| 12 | |
| 13 | Available materials: |
| 14 | - silver |
| 15 | - copper |
| 16 | - aluminium |
| 17 | - tungsten |
| 18 | - iron |
| 19 | - steel |
| 20 | - zinc |
| 21 | - solder""" |
| 22 | |
| 23 | materials = { |
| 24 | "silver": {"rho": 0.0163, "coefficient": 0.0038}, |
| 25 | "copper": {"rho": 0.0178, "coefficient": 0.00381}, |
| 26 | "aluminium": {"rho": 0.0284, "coefficient": 0.004}, |
| 27 | "tungsten": {"rho": 0.055, "coefficient": 0.0045}, |
| 28 | "iron": {"rho": 0.098, "coefficient": 0.006}, |
| 29 | "steel": {"rho": 0.15, "coefficient": 0.0047}, |
| 30 | "zinc": {"rho": 0.06, "coefficient": 0.0037}, |
| 31 | "solder": {"rho": 0.12, "coefficient": 0.0043}, |
| 32 | } |
| 33 | |
| 34 | rho_20deg = materials[material]["rho"] |
| 35 | temp_coefficient = materials[material]["coefficient"] |
| 36 | |
| 37 | rho = rho_20deg * (1 + temp_coefficient * (temperature - 20)) |
| 38 | resistance = rho * length / section |
| 39 | |
| 40 | return f"{resistance}Ω" |
nothing calls this directly
no outgoing calls
no test coverage detected