from math import sqrt,pi,atan
# If a R=30ohms and Xc=40ohms are in series with 100V applied, find the following: Zt, I, Vr, Vc and Theta z. What is the phase angle between Vc and Vr with respect to I? Prove that the sum of the series voltage drop equals the applied voltage Vt
# Given data
R = 30.# # Resistance=30 Ohms
Xc = 40.# # Capacitive Reactance=40 Ohms
Vt = 100.# # Applied Voltage=100 Volts
R1 = R*R#
Xc1 = Xc*Xc#
Zt = sqrt(R1+Xc1)#
print 'Zt = %0.2f Ohms'%Zt
I = (Vt/Zt)#
print 'I = %0.2f Ampers'%I
Vr = I*R#
print 'Voltage Across Resistor = %02.f Volts'%Vr
Vc = I*Xc#
print 'Voltage Across Capacitive Reactance = %0.2f Volts'%Vc
Oz = atan(-(Xc/R))*180/pi
print 'Theta z =%0.2f degree'%Oz
#Prove that the sum of the series voltage drop equals the applied voltage Vt
Vt = sqrt((Vr*Vr)+(Vc*Vc))#
print 'Sum of Voltage Drop is Equal to Applied Voltage of 100V = %0.2f Volts'%Vt
from math import sqrt,pi,atan
# A 30-mA Ir is in parallel with another branch current of 40 mA for Ic. The applied voltage Va is 72 V. Calculate It, Zeq and Theta I.
# Given data
Ir = 30.*10**-3# # Current Ir=30 mA
Ic = 40.*10**-3# # Current Ic=40 mA
Va = 72.# # Applied Voltage=72 Volts
A = Ir*Ir#
B = Ic*Ic#
It = sqrt(A+B)#
print 'The Total Current = %0.2f Amps'%It
print 'i.e 50 mAmps'
Zeq = Va/It#
print 'The Equivqlent Impedence = %0.2f Ohms'%Zeq
print 'i.e 1.44 kohms'
Oi = atan(Ic/Ir)*180/pi
print 'The Value of Theta I = %0.2f degrees'%Oi