-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.py
162 lines (110 loc) Β· 4.54 KB
/
App.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
print("******************************* WELCOME TO THE RESISTANCE CALCULATOR ********************************")
print("*****************************************************************************************************\n")
print("PLEASE CHOOSE THE KIND OF RESISTANCE YOU WISH TO CALCULATE")
print("ENTER 1 FOR VOLTAGE & RESISTANCE IN SERIES\nENTER 2 FOR VOLTAGE & RESISTANCE IN PARALLEL\nENTER 3 FOR VOLTAGE & BOTH TYPE OF RESISTANCES")
choice = int(input())
if choice == 1:
print("ENTER THE CURRENT IN THE SYSTEM")
I = float(input())
# I means current
print("ENTER THE TOTAL NUMBER OF RESISTORS IN SERIES")
Rst = int(input())
# Rst means total number of resistors in series
print("ENTER A UNIT VALUE FOR EACH OF THE",Rst,"RESISTORS CONNECTED IN SERIES")
# Rsv = int
# Rsv means value of sum of resistance in series
RstList = []
# RstList is the list that holds Rst in order to calculate Rsv
for Rst in range(0,Rst,1):
print("ENTER A RESISTOR UNIT VALUE")
Rsuv = float(input())
# Rsuv means series resistance unit value
RstList.append(Rsuv)
Rs = sum(RstList)
# Rs means resistance in series
print("RESISTANCE IN SERIES IS: %0.2f"%Rs,"β¦")
V = float(I*Rs)
# V means voltage
print("ANY APARATUS CONNECTED TO THIS CIRCUIT SHOULD BE ABLE TO SUPPORT AT LEAST %0.2f"%V,"VOLTS")
elif choice == 2:
print("ENTER THE CURRENT IN THE SYSTEM")
I = float(input())
# I means current
print("PLEASE ENTER THE TOTAL NUMBER OF RESISTORS IN PARALLEL")
Rpt = int(input())
# Rpt means total number of resistors in parallel
print("ENTER A UNIT VALUE FOR EACH OF THE",Rpt,"RESISTORS CONNECTED IN PARALLEL")
# Rpv = float
# Rpv means value of sum of resistance in parallel
RptList = []
# RptList is the list that holds Rpt in order to calculate Rpv
for Rpt in range(0,Rpt,1):
print("ENTER A RESISTOR UNIT VALUE")
Rpuv = float(input())
# Rpuv means parallel resistance unit value
RptList.append(Rpuv)
def product(RptList):
product = 1
for i in RptList:
product = product * i
return product
Rpsl = sum(RptList)
# Rpsl means sum of the Rptlist
Rp = float(product(RptList)/Rpsl)
# Rp means resistance in series
print("RESISTANCE IN PARALLEL IS: %0.2f"%Rp,"β¦")
V = float(I*Rp)
# V means voltage
print("ANY APARATUS CONNECTED TO THIS CIRCUIT SHOULD BE ABLE TO SUPPORT AT LEAST %0.2f"%V,"VOLTS")
elif choice == 3:
print("ENTER THE CURRENT IN THE SYSTEM")
I = float(input())
# I means current
print("ENTER THE TOTAL NUMBER OF RESISTORS IN SERIES")
Rst = int(input())
# Rst means total number of resistors in series
print("ENTER A UNIT VALUE FOR EACH OF THE",Rst,"RESISTORS CONNECTED IN SERIES")
# Rsv = int
# Rsv means value of sum of resistance in series
RstList = []
# RstList is the list that holds Rst in order to calculate Rsv
for Rst in range(0,Rst,1):
print("ENTER A RESISTOR UNIT VALUE")
Rsuv = float(input())
# Rsuv means series resistance unit value
RstList.append(Rsuv)
Rs = sum(RstList)
# Rs means resistance in series
print("RESISTANCE IN SERIES IS: %0.2f"%Rs,"β¦")
print("PLEASE ENTER THE TOTAL NUMBER OF RESISTORS IN PARALLEL")
Rpt = int(input())
# Rpt means total number of resistors in parallel
print("ENTER A UNIT VALUE FOR EACH OF THE",Rpt,"RESISTORS CONNECTED IN PARALLEL")
# Rpv = float
# Rpv means value of sum of resistance in parallel
RptList = []
# RptList is the list that holds Rpt in order to calculate Rpv
for Rpt in range(0,Rpt,1):
print("ENTER A RESISTOR UNIT VALUE")
Rpuv = float(input())
# Rpuv means parallel resistance unit value
RptList.append(Rpuv)
def product(RptList):
product = 1
for i in RptList:
product = product * i
return product
Rpsl = sum(RptList)
# Rpsl means sum of the Rptlist
Rp = float(product(RptList)/Rpsl)
# Rp means resistance in series
print("RESISTANCE IN PARALLEL IS: %0.2f"%Rp,"β¦")
Rspt = Rp+Rs
# Rspt means the total resistance of a circuit containing both series and parallel connections
print("THE TOTAL RESISTANCE IS: %0.2f"%Rspt,"β¦")
V = float(I*Rspt)
# V means voltage
print("ANY APARATUS CONNECTED TO THIS CIRCUIT SHOULD BE ABLE TO SUPPORT AT LEAST %0.2f"%V,"VOLTS")
else:
print("ERROR!!! CHOOSE ANY OPTION FROM 1 TO 3")
print("RE-RUN THE PROGRAM")