#Caption:Calculate voltage after 8ms
c=1.#Capacitance of capacitor(in micro farad)
vs=6.#Source voltage(in volts)
r=10.#Resistor(in kilo ohm)
vi=-3.#Initial voltage(in volts)
t=8.#Time (in milli sec)
e=vs-((vs-vi)*2.718**(-t/(r*c)))
print '%s %.2f' %('Voltage after 8ms(in volts)=',e)
#Caption:Determine (a)Ec at 1.5ms (b)Ec at 6ms
r1=1.#Resistor(in kilo ohm)
c1=1.#Capacitance(in micro farad)
e1=10.#Voltage(in volts)
r2=20.#Resistor(in kilo ohm)
c2=0.1#Capacitance(in micro farad)
e2=12.#Voltage(in volts)
t1=r1*c1*0.78
e=e1*1.
ec1=e*t1
t2=r2*c2*0.025
E=e2*1.
ec2=E*t2
print '%s %.1f %s %.1f'%('(a)Ec at 1.5ms(in volts) =',ec1,'\n(b)Ec at 6ms(in volts) =',ec2)
#Caption:Calculate Rise time,time for capacitor to charge to required amount and time required for complete charging
V=5.#Voltage source(in volts)
r=39.#Resistor(in kilo ohm)
c=500.#Capacitance of capacitor(in pf)
tr=2.2*r*c*10.**(-3)
t=r*c*10.**(-3)
tc=5*r*c*10.**(-3)
print '%s %.1f %s %.1f %s %.1f' %('Rise time=',tr,'\ntime for 63.2% charging=',t,'\nand time required for complete charging(in micro sec)=',tc)
#Caption:Calculate minimum square wave frequency
C=1.#Coupling capacitor(in micro farad)
R=1.#Input resistance(in Mega ohm)
t=0.01#Tilt
PW=t*R*C
f=1./(2.*PW)
print '%s %.f' %('Frequency required(in hertz)=',f)
#Caption:Determine fastest rise time
r=600.#Output resistance(in ohms)
c=30.#Input capacitance(in pf)
tr=2.2*r*c*10.**(-3)
print '%s %.1f' %('Fastest rise time(in ns)=',tr)
#Caption:Calculate voltage at 14 ms
Eo=0#Voltage at t=0sec(in volt)
E=20.#Peak voltage(in volts)
r=3.3#Resistance(in kilo ohm)
c=1.#Capacitance(in micro farad)
t1=4.#Time(in ms)
t2=2.#Time(in ms)
e1=E-((E-Eo)*(2.718)**(-t1/(r*c)))
e2=Eo-((Eo-e1)*(2.718)**(-t1/(r*c)))
e3=E-((E-e2)*(2.718)**(-t1/(r*c)))
e3=Eo-((Eo-e3)*(2.718)**(-t2/(r*c)))
print '%s %.2f' %('Voltage at 14ms(in volts)=',e3)
#Caption:Determine max and min voltage at which capacitor voltage will settle
E=20.#Peak voltage(in volts)
t=4.#Time interval(in ms)
r=3.3#Resistance(in kilo ohms)
c=1.#Capacitance(in micro farad)
Emax=E/(1.+(2.718**(-t/(r*c))))
Emin=E-Emax
print '%s %.2f %s %.2f' %('Maximum voltage(in volts)=',Emax, '\n minimum voltage(in volts)=',Emin)
#Caption:Calculate output voltage for (a)10V and 1ms Pw (b)10V and 2ms PW (c)20V and 1ms PW
e1=10.#Voltage applied(in volts)
e0=0#Voltage at t=0sec(in volts)
t1=1.#PW(in ms)
t2=2.#PW(in ms)
e2=20.#Input voltage(in volts)
r=10.#Resistance(in kilo ohm)
c=20.#Capacitance(in micro farad)
eo1=(e1-((e1-e0)*(2.718)**(-t1/(r*c))))*1000
eo2=(e1-((e1-e0)*(2.718)**(-t2/(r*c))))*1000
eo3=(e2-((e2-e0)*(2.718)**(-t1/(r*c))))*1000
print '%s %.f %s %.f %s %.f' %('Output voltage for\n(a)(in mv)=',eo1,'\n(b)(in mv)=',eo2,'\n(c)(in mv)=',eo3)
#Caption:Calculate output voltage for (a)10V and (b)20V
E1=10.#Input voltage(in volts)
E2=20.#Input voltage(in volts)
c=1.#Capacitance(in micro farad)
r=1.#Resistance(in kilo ohm)
t=100.#Pulse width(in ms)
i1=(c*E1*10.**(-6.))/(t*10.**(-3.))
eo1=i1*r*1000.
print '%s %.1f' %('Output voltage for (a)(in volts)=',eo1)
i2=(c*E2*10.**(-6.)/(t*10.**(-3.)))
eo2=i2*r*1000.
print '%s %.1f' %('Output voltage for (b)(in volts)=',eo2)
#Caption:Calculate amplitude of output waveform for (a)Rise time (b)Fall time
r=1.#Resistance(in kilo ohm)
c=100.#Capacitance(in pf)
tr=1.#Rise time(in micro sec)
tf=3.#Fall time(in micro sec)
e1=8.#Change in voltage for rise time(in volts)
e2=-8.#Change in voltage for fall time(in volts)
eo1=r*c*0.001*e1/tr
print '%s %.1f' %('Amplitude of output waveform for (a)Rise time(in volts)=',eo1)
eo2=r*c*0.001*e2/tf
print '%s %.2f' %('Amplitude of output waveform for (b)Fall time(in volts)=',eo2)