In [2]:

```
#Variable declaration
R1=1000.#R1=input resistance in ohms in the inverting amplifier circuit
Rf=3*1000#Rf=feedback resistance in ohms
v1=2#v1=input voltage in the inverting terminal of an amplifier circuit
#Calculations&Results
vo=-(Rf/R1)*v1#vo=output voltage
print "Output voltage is=%.f V"%vo
print "Output voltage is negative as it is the circuit of inverting amplifier"
print "Input resistance Rin=R1 is = %.f k ohm"%(R1/1000)
i=v1/R1#i=input current
print "The input currrent is = %.f mA"%(i*1000)
```

In [4]:

```
#Variable declaration
R1=2*1000#R1=input resistance in ohms in the non-inverting amplifier circuit
Rf=5.*1000#Rf=feedback resistance in ohms
#Calculations
AV=1+(Rf/R1)#AV=voltage gain of the non-inverting amplifier circuit
#Result
print "The voltage gain of the given non-inverting amplifier circuit is = %.1f"%AV
```

In [6]:

```
#Variable declaration
#First case
v1=40.*10**-6#v1=voltage applied to the non-inverting input terminal
v2=-40*10**-6#v2=voltage applied to the inverting input terminal
vo=100*10**-3#vo=output voltage for the above inputs v1 and v2
#Second case
V1=40*10**-6#V1=voltage applied to the non-inverting input terminal
V2=40*10**-6#V2=voltage applied to the inverting input terminal
Vo=0.4*10**-3#Vo=output voltage for the above inputs V1 and V2
#Calculations&Results
print "In first case:"
vd=v1-v2#vd=difference signal voltage
print "vd=%.f µV"%(vd/10**-6)
vc=(v1+v2)/2#vc=common mode signal voltage
print "vc=%.f µV"%(vc/10**-6)
#Output voltage is vo=(Ad*vd)+(Ac*vc) where Ad and Ac are the voltage gains for the difference signal and the common-mode signal,respectively
Ad=vo/vd#Ad calculated in first case as common mode signal vc=0
print "Voltage gain for the difference signal is Ad = %.f"%Ad
print "\nIn second case:"
Vd=V1-V2#Vd=difference signal voltage
print "Vd=%.f µV"%(Vd/10**-6)
Vc=(V1+V2)/2#Vc=common mode signal voltage
print "Vc=%.f µV"%(Vc/10**-6)
Ac=Vo/Vc#Ac calculated in second case as difference signal Vc=0
print "Voltage gain for the common-mode signal is Ac = %.f"%Ac
CMRR=abs(Ad/Ac)#CMRR=Common Mode Rejection Ratio=|Ad/Ac|
print "Common Mode Rejection Ratio is CMRR=%.f"%CMRR
```

In [7]:

```
#Variable declaration
R1=1*1000#R1=input resistance in ohms in the inverting terminal of the amplifier circuit
R2=200#R2=input resistance in ohms in the inverting terminal of the amplifier circuit
R3=400#R3=input resistance in ohms in the inverting terminal of the amplifier circuit
Rf=500.#Rf=feedback resistance in ohms
v1=-5#v1=input voltage in the inverting terminal of an amplifier circuit at R1 resistor
v2=3#v2=input voltage in the inverting terminal of an amplifier circuit at R2 resistor
v3=4#v3=input voltage in the inverting terminal of an amplifier circuit at R3 resistor
#Calculations
vo=-(((Rf/R1)*v1)+((Rf/R2)*v2)+((Rf/R3)*v3))#vo=output voltage for inverting summing summing amplifier circuit
#Result
print "Output voltage of the 3-input summing amplifier circuit is = %.f V"%vo
print "Output voltage is negative as it the circuit of inverting summing amplifier"
```

In [9]:

```
import math
#Variable declaration
R1=1*1000#R1=input resistance in ohms in the inverting amplifier circuit
Rf=50*1000#Rf=feedback resistance in ohms
#Calculations&Results
A=-(Rf/R1)#AV=voltage gain of the inverting amplifier circuit
print "The voltage gain of the given inverting amplifier circuit is = %.f"%A
#vin=0.5*sin(100*math.pi*t)
#vout=A*vin=-50*0.5*sin(100*math.pi*t)=-25*sin(100*math.pi*t)
print "If the operation were entirely linear ,the output voltage would have been -25*sin(100*math.pi*t)"
print "But since the voltage supply is +-12V ,the op-amp is saturated when |vout| attains 12V"
#Let at time t=to,vout=-12V
#-12=-25*sin(100*math.pi*to)
to=(1./(100*math.pi))*math.asin(12./25)
print "to=%.2e s"%to
print "Thus over the entire cycle,"
print "vout=-25*sin(100*math.pi*t) V when 0<=t<=to"
print "vout=-12V when to<=t<=(0.01-to)"
print "vout=-25*sin(100*math.pi*t) V when (0.01-to)<=t<=(0.01+to)"
print "vout=+12V when (0.01+to)<=t<=(0.02-to)"
print "vout=-25*sin(100*math.pi*t) V when (0.02-to)<=t<=0.02 seconds"
```

In [13]:

```
#Variable declaration
R=2.*1000#R=feedback resistance in ohms in the differentiator circuit
C=0.01*10**-6#C=input capacitance in farad in the differentiator circuit
#Calculations&Results
#dvi/dt=1.5V/1ms for 0<t<1ms (given ramp input signal)
#output voltage of a differentiator is given as vo=-RC(dvi/dt)
d=1.5/(10**-3)#d=dvi/dt=1.5V/1ms
vo=-R*C*d
#Results
print "Output voltage of a differentiator is %.2f V"%vo
print "Hence for <t<1 ms,vo=-0.03V=-30mV.Otherwise,vo=0V"
```

In [14]:

```
#Variable declaration
R1=5*1000#R1=input resistance in ohms in the given op-amp circuit
Rf=10.*1000#Rf=feedback resistance in ohms
vi=5#vi=input voltage at the inverting terminal of an op-amp
V=4#V=voltage at the non-inverting terminal of an op-amp
#Calculations
#By applying superposition theorem
Vo=((1+(Rf/R1))*V)+(-(Rf/R1)*vi)
#Result
print "Output voltage Vo of the circuit is = %.f V"%Vo
```

In [16]:

```
#Variable declaration
R1=10*1000#R1=resistance in ohms
R2=100#R2=resistance in ohms
R3=10*1000#R3=resistance in ohms
R4=10*1000#R4=resistance in ohms
R5=10*1000#R5=resistance in ohms
#Calculations
#Since the voltage gains of the OP AMPs are infinite,the voltages of the points X and Y in the given figure are V1 and V2 respectively
#Applying Kirchhoff's current law at X
#(V1/R1)+((V1-V)/R3)+((V1-V2)/R2)=0
#Applying Kirchhoff's current law at Y
#((V2-V)/R4)+((V2-V1)/R2)+((V2-Vo)/R5)=0
#Eliminating V from the above equations
#V2*((1/R2)+(1/R4)+(1/R5)+(R3/(R2*R4)))-V1*((1/R2)+(1/R4)+((R3/R4)*((1/R1)+(1/R2))))=Vo/R5
#V2*R-V1*r=Vo/R5...................(1)
R=((1./R2)+(1/R4)+(1/R5)+(R3/(R2*R4)))
r=((1./R2)+(1/R4)+((R3/R4)*((1/R1)+(1/R2))))
#Results
print "R=%.2f"%R
print "r=%.2f"%r
#R=r from above calculation and its answer displayed
#Hence from the above equation (1) A=Vo/(V1-V2)=-(R5*R)=-(R5*r)
print "Differential mode gain A=Vo/(V1-V2)=%.f"%(-R5*r)
```