Skip to content

Commit

Permalink
Add exception handling
Browse files Browse the repository at this point in the history
  • Loading branch information
16ratneshkumar authored Jul 29, 2024
1 parent 5aa23ca commit 819313a
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions Calculate resistance.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
def res(R1, R2):
sum = R1 + R2
if (option =="series"):
return sum
else:
return (R1 * R2)/(R1 + R2)
Resistance1 = int(input("Enter R1 : "))
Resistance2 = int(input("Enter R2 : "))
option = str(input("Enter series or parallel :"))
print("\n")
R = res(Resistance1,Resistance2 )
print("The total resistance is", R)
def res(R1, R2):
sum = R1 + R2
if option =="series":
return sum
elif option =="parallel" :
return (R1 * R2)/sum
return 0
Resistance1 = int(input("Enter R1 : "))
Resistance2 = int(input("Enter R2 : "))
option = input("Enter series or parallel :")
print("\n")
R = res(Resistance1,Resistance2 )
if R==0:
print('Wrong Input!!' )
else:
print("The total resistance is", R)

0 comments on commit 819313a

Please sign in to comment.