#using equation based method
V=int (input ("Enter the bulb rated/supply voltage: ") )
n=int (input ("Enter number of bulbs connected in series: "))
power-list ()
resistance=list ()
power_c=list ()
total=0
total_p=0
for pr in range (1,n+1) :
power.append (int (input (f"Enter the power rating of the Bulb (pr? (W): ") ))
for p in power:
resistance.append (V**2/p)
for tr in range (0, len (resistance)) :
total=total+resistance [tr]
current=V/total
for rc in resistance:
power c.append (current**2*rc)
print (power c)
max_power_c=max (power_c)
max_index=power_c. index (max power_c)
for pc in range (0, len (power_c)) :
total_p+=power_c[pc]
print ("Total power consumed is (a:5.3F} W ".format (a=total p)) print ("The (W bulb will glow brighter". format (power [max_ index]) )
#using single for loop:|
V=int (input ("Enter the bulb rated/supply voltage: "))
n=int (input ("Enter number of bulbs connected in series: "))
power=list () #power ratings
prated=list ()
resistance=list ()
power c=list ()
total R=0
total p=0
for pr in range (1,n+1) :
power= (int (input (f"Enter the power rating of Bulb (pr} (W): ")))
prated. append (power) resistance=V**2/power
total R+=resistance
current=V/total R
power c=current**2*total R
print ("Total power consumed is {a:5.2f} W ". format (a=power c))
print ("The fiw bulb will glow brighter". format (min (prated) >)
#using functions:
total R=0
def power_consumed (v, p) :
resistance=v**2/p
global total R
total R+=resistance
current=v/total R
return current**2*total R
def main () :
V=int (input ("Enter the bulb rated/supply voltage: ") )
n=int (input ("Enter number of bulbs connected in series: "))
prated=list ()
pc=list ()
for pr in range (1, n+1) :
power=int(input(f"Enter the power rating of Bulb(pr)(W):"))
prated. append (power)
pc=power_ consumed (V, power)
print ("Total power consumed is {a:5.2f) W". format (a=pc) )
print ("The (W bulb will glow brighter". format (min (prated) ) )
main ( )