Professional Documents
Culture Documents
Activity 3
Activity 3
resistors = []
while True:
print("\nChoose a number in the following options.")
print("Options:")
print(" 1. Add a resistor")
print(" 2. Calculate total resistance")
print(" 3. Exit")
if choice == "1":
# Add a resistor
resistance = input("Enter the resistance value: ")
else:
# The user must be prompted to enter the connection type (series or
parallel).
connection_type = input("Enter the connection type (series or
parallel): ")
# The program will sum up all the resistance values to calculate the
total resistance.
# The total resistance value will be displayed with two decimal
places.
if connection_type.lower() == "series":
total_resistance = sum(resistors)
print(f"Total resistance: {total_resistance:.2f} ohms")
else:
print("Invalid choice. Please try again.")