We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 5aa23ca commit 819313aCopy full SHA for 819313a
Calculate resistance.py
@@ -1,12 +1,16 @@
1
-def res(R1, R2):
2
- sum = R1 + R2
3
- if (option =="series"):
4
- return sum
5
- else:
6
- return (R1 * R2)/(R1 + R2)
7
-Resistance1 = int(input("Enter R1 : "))
8
-Resistance2 = int(input("Enter R2 : "))
9
-option = str(input("Enter series or parallel :"))
10
-print("\n")
11
-R = res(Resistance1,Resistance2 )
12
-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 )
13
+if R==0:
14
+ print('Wrong Input!!' )
15
+else:
16
+ print("The total resistance is", R)
0 commit comments