This Python program receives two numeric inputs from the user:
1. The resistance of an electrical circuit (in ohms)
2. The current flowing through the circuit (in amperes)
It then calculates the voltage using Ohm’s Law:
Voltage = Current × Resistance
# Get resistance and current from user
resistance = float(input("Enter resistance (ohms): "))
current = float(input("Enter current (amperes): "))
# Calculate voltage
voltage = resistance * current
# Display result
print("\n--- Result ---")
print(f"Voltage of the circuit is: {voltage:.2f} volts")
Enter resistance (ohms): 10
Enter current (amperes): 2.5
--- Result ---
Voltage of the circuit is: 25.00 volts
- Resistance and current are received using input() and converted to float values
- Voltage is calculated using the formula V = I × R
- The result is displayed with two decimal places for clarity