![]() |
dc circuit calculations - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Homework (https://python-forum.io/forum-9.html) +--- Thread: dc circuit calculations (/thread-5960.html) |
dc circuit calculations - michaelj - Oct-30-2017 hi guys i am having difficulty getting my calculation for total current to display. im a total beginner, any guidance appreciated resistors = [0] rt = resistors def ObtainResistors(resistors): for i in range(1, 8): value = int(input('please enter resistor %d:' % i)) resistors.append(value) def TotalResistance(resistors): rt1 = ((resistors[2] * resistors[3]) / (resistors[2] + resistors[3])) print(rt1, 'ohms') rt2 = (rt1 + resistors[4]) print(rt2, 'ohms') rt3 = ((rt2 * resistors[5]) / (rt2 + resistors[5])) print(rt3, 'ohms') rt4 = (rt3 + resistors[7]) print(rt4, 'ohms') rt5 = ((rt4 * resistors[6]) / (rt4 + resistors[6])) print(rt5, 'ohms') rt6 = (rt5 + resistors[1]) print(rt6, 'ohms') rt = (rt1 + rt2 + rt3 + rt4 + rt5 + rt6) print(rt, 'ohms') resistors.append(rt) voltage = def getvoltage(voltage): value = int(input('please enter supply voltage:')) print(voltage, 'volts') voltage.append(value) itotal = def current(itotal): TotalResistance(resistors) amps = (voltage, '/', resistors.pop(9)) print((voltage, '/', rt, 'amps')) itotal.append(amps) ObtainResistors(resistors) print(resistors) TotalResistance(resistors) print(resistors) getvoltage(voltage) print(voltage) current(itotal) print(itotal) please enter resistor 1:1 please enter resistor 2:1 please enter resistor 3:1 please enter resistor 4:1 please enter resistor 5:1 please enter resistor 6:1 please enter resistor 7:1 [0, 1, 1, 1, 1, 1, 1, 1] 0.5 ohms 1.5 ohms 0.6 ohms 1.6 ohms 0.6153846153846154 ohms 1.6153846153846154 ohms 6.430769230769231 ohms [0, 1, 1, 1, 1, 1, 1, 1, 6.430769230769231] please enter supply voltage:10 volts [10] 0.5 ohms 1.5 ohms 0.6 ohms 1.6 ohms 0.6153846153846154 ohms 1.6153846153846154 ohms 6.430769230769231 ohms ([10], '/', [0, 1, 1, 1, 1, 1, 1, 1, 6.430769230769231], 'amps') [([10], '/', 6.430769230769231)] Process finished with exit code 0 RE: dc circuit calculations - heiner55 - Nov-01-2017 What is your question ? |