Part of the series

Several example codes

~1 min read • Updated Sep 29, 2025

Program Overview

This Python program receives three resistance values from the user and calculates the total resistance.
In this version, we assume the resistors are connected in series, so the total resistance is simply the sum:
RT = R1 + R2 + R3


Python Code:


# Get three resistance values from user
R1 = float(input("Enter resistance R1 (ohms): "))
R2 = float(input("Enter resistance R2 (ohms): "))
R3 = float(input("Enter resistance R3 (ohms): "))

# Calculate total resistance
RT = R1 + R2 + R3

# Display result
print("\n--- Result ---")
print(f"Total resistance RT = {RT:.2f} ohms")

Sample Output:


Enter resistance R1 (ohms): 100  
Enter resistance R2 (ohms): 150  
Enter resistance R3 (ohms): 50  

--- Result ---  
Total resistance RT = 300.00 ohms

Explanation:

- The resistance values are received using input() and converted to float
- The total resistance is calculated by summing the three values
- The result is displayed with two decimal places for clarity


Written & researched by Dr. Shahin Siami