This function can calculate the resonant frequency of LC circuit, for the given value of inductance and capacitnace. Examples are given below: >>> resonant_frequency(inductance=10, capacitance=5) ('Resonant frequency', 0.022507907903927652) >>> resonant_frequency(inductance
(inductance: float, capacitance: float)
| 14 | |
| 15 | |
| 16 | def resonant_frequency(inductance: float, capacitance: float) -> tuple: |
| 17 | """ |
| 18 | This function can calculate the resonant frequency of LC circuit, |
| 19 | for the given value of inductance and capacitnace. |
| 20 | |
| 21 | Examples are given below: |
| 22 | >>> resonant_frequency(inductance=10, capacitance=5) |
| 23 | ('Resonant frequency', 0.022507907903927652) |
| 24 | >>> resonant_frequency(inductance=0, capacitance=5) |
| 25 | Traceback (most recent call last): |
| 26 | ... |
| 27 | ValueError: Inductance cannot be 0 or negative |
| 28 | >>> resonant_frequency(inductance=10, capacitance=0) |
| 29 | Traceback (most recent call last): |
| 30 | ... |
| 31 | ValueError: Capacitance cannot be 0 or negative |
| 32 | """ |
| 33 | |
| 34 | if inductance <= 0: |
| 35 | raise ValueError("Inductance cannot be 0 or negative") |
| 36 | |
| 37 | elif capacitance <= 0: |
| 38 | raise ValueError("Capacitance cannot be 0 or negative") |
| 39 | |
| 40 | else: |
| 41 | return ( |
| 42 | "Resonant frequency", |
| 43 | float(1 / (2 * pi * (sqrt(inductance * capacitance)))), |
| 44 | ) |
| 45 | |
| 46 | |
| 47 | if __name__ == "__main__": |
nothing calls this directly
no outgoing calls
no test coverage detected