Jump to content



Photo
- - - - -

Parallel Resistors One Over Formula Program

python

  • Please log in to reply
No replies to this topic

#1 satchell

satchell

    Newbie

  • Members
  • Pip
  • 3 posts

  • Calculators:
    fx-CG50, fx-991EX

Posted 25 September 2022 - 06:38 PM

Wrote a python program for the Casio fx-CG50 to do the One Over method for parallel resistors. Basically you'd enter the R1 and R2 values and 0 for R3 to get the simple || result. Or enter up to R5...
 
If you need more resistors you can iterate on the if statements.
 
from math import*

a = float(input("R1 Value = "))
b = float(input("R2 Value = "))
c = float(input("R3 Value = "))

if  c == 0:
    firstOneOver = (1/a)+(1/b)
    solution = (1/firstOneOver)
    print(solution)
if c > 0:
    d = float(input("R4 Value = "))
    if d == 0:
        secondOneOver = (1/a)+(1/b)+(1/c)
        solution = (1/secondOneOver)
        print(solution)
    if d > 0:
        e = float(input("R5 Value = "))
        if e == 0:
            thirdOneOver = (1/a)+(1/b)+(1/c)+(1/d)
            solution = (1/thirdOneOver)
            print(solution)
        if e > 0:
            fourthOneOver = (1/a)+(1/b)+(1/c)+(1/d)+(1/e)
            solution = (1/fourthOneOver)
            print(solution)

 







Also tagged with one or more of these keywords: python

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users