Resistor in Series and Parallel

In this blog post we will create a Python program that will help us calculate the total resistance when two resistors are connected either in series or in parallel.

This program will be based on the following formulae:
resistors-formulae

Program Flowchart


resistors-flowchart

Create the Code


Your task consists of implementing the code described in the above flowchart using Python. Then you will have to test your code by completing the test plan below.

Test Plan


Once your code is done, complete the following tests to check that your code is working as it should:

Test # Input Values Expected Output Actual Output
#1 R1: 6 (Ohms)
R2: 6 (Ohms)
Series
12 Ohms
#2 R1: 6 (Ohms)
R2: 6 (Ohms)
Parallel
3 Ohms
#3 R1: 6 (Ohms)
R2: 12 (Ohms)
Series
18 Ohms
#4 R1: 6 (Ohms)
R2: 12 (Ohms)
Parallel
4 Ohms
#5 R1: 33000 (Ohms)
R2: 56000 (Ohms)
Series
89000 Ohms
#6 R1: 33000 (Ohms)
R2: 56000 (Ohms)
Parallel
20764 Ohms
Share Button
Posted in Python, Python - Beginner

Leave a Reply

Our Latest Book