In [1]:

```
from __future__ import division
# For an op-amp circuit find a) closed loop gain Acl b) input impedance Zin c) output impedance Zo
ro = 85 # # ohm
A = 150*10**3 # # ohm
R2 = 350*10**3 # # ohm # Feedback resistance
R1 = 10*10**3 # # ohm # Input resistance
# a) closed loop gain
# ACL = abs(Vo/Vin) = abs(R2/R1)
ACL = abs(R2/R1) #
print ' closed loop gain of an op-amp is = %0.2f'%ACL# # 1/beta = ACL
beta = (1/ACL) #
# b) the input impedance Zin
Zin = R1 #
print ' the input impedance Zin = %0.2f'%(Zin/1e3),'kohm '#
# c0 the output impedance Z0
Z0 = (ro)/(1+(beta*A))#
print ' the output impedance Z0 = %0.3f'%Z0,' ohm '#
```

In [2]:

```
# Determine the differece voltage and open loop gain of an op-amp
V1 = -5 # # volt # input voltage
V2 = 5 # # volt
Vo = 20 # #volt # output voltage
# the difference voltage is given by
Vd = V2-V1 #
print ' The difference voltage is = %0.2f'%Vd,' V '
# open loop gain
A = (Vo/Vd)#
print ' The open loop gain is = %0.2f'%A,' '
```

In [3]:

```
# Determine the differece voltage and open loop gain of an op-amp
V1 = -5 # # volt # input voltage
V2 = 0 # # volt # GND
Vo = 20 # #volt # output voltage
# the difference voltage is given by
Vd = V2-V1 #
print ' The difference voltage is = %0.2f'%Vd,' V '
# open loop gain
A = (Vo/Vd)#
print ' The open loop gain is = %0.2f'%A,' '
```

In [4]:

```
# Determine the differece voltage and open loop gain of an op-amp
V1 = 0 # # volt # input voltage # GND
V2 = 5 # # volt
Vo = 20 # #volt # output voltage
# the difference voltage is given by
Vd = V2-V1 #
print ' The difference voltage is = %0.2f'%Vd,' V '
# open loop gain
A = (Vo/Vd)#
print ' The open loop gain is = %0.2f'%A,' '
```

In [5]:

```
# Determine the differece voltage and open loop gain of an op-amp
V1 = 5 # # volt # input voltage # GND
V2 = -5 # # volt
Vo = -20 # #volt # output voltage
# the difference voltage is given by
Vd = V2-V1 #
print ' The difference voltage is = %0.2f'%Vd,' V '
# open loop gain
A = (Vo/Vd)#
print ' The open loop gain is = %0.2f'%A,' '
```

In [6]:

```
from __future__ import division
# To find closed loop gain and output voltage Vo of an inverting op-amp
R1 = 10 # #kilo ohm # input resistance
R2 = 25 # # kilo ohm # feedback resistance
Vin = 10 # #volt # input voltage
# Closed loop gain of an inverting op-amp
Ac = -(R2/R1) #
print 'The Closed loop gain of an inverting op-amp is = %0.2f'%Ac,' '
Ac = abs(Ac)#
print 'The |Ac| Closed loop gain of an inverting op-amp is = %0.2f'%Ac,' '
# the output voltage of an inverting op-amp
Vo = -(R2/R1)*Vin #
print 'The output voltage of an inverting op-amp is = %0.2f'%Vo,' V '
```

In [7]:

```
from __future__ import division
# To find closed loop gain and output voltage Vo of an non-inverting op-amp
R1 = 10 # #kilo ohm # input resistance
R2 = 25 # # kilo ohm # feedback resistance
Vin = 10 # #volt # input voltage
# Closed loop gain of an non-inverting op-amp
Ac = 1+(R2/R1) #
Ac = abs(Ac)#
print ' The Closed loop gain of an non-inverting op-amp is = %0.2f'%Ac,' '
# the output voltage of an inverting op-amp
Vo = (1+R2/R1)*Vin #
print ' The output voltage of an non-inverting op-amp is = %0.2f'%Vo,' V '
```

In [8]:

```
from __future__ import division
# to find out closed loop gain and output voltage Vo
R1 = 10 # #kilo ohm # input resistance
R3 = 10 # #kilo ohm # input resistance
R2 = 25 # # kilo ohm # feedback resistance
R4 = 25 # # kilo ohm # feedback resistance
Vin2 = 10 # #volt # input voltage
Vin1 = -10 # #volt # input voltage
# closed loop gain of differntial op-amp is given by
Ac = (R2/R1) #
Ac = abs(Ac)#
print 'The closed loop gain of differntial op-amp is = %0.2f'%Ac,' '
# the output voltage of an non-inverting op-amp is given by
Vo = (R2/R1)*(Vin2-Vin1) #
print 'The output voltage of an non-inverting op-amp is= %0.2f'%Vo,' V '
```

In [9]:

```
from __future__ import division
# Determine the non-inverting input voltage
R1 = 10 # #kilo ohm # input resistance
R2 = 25 # #kilo ohm # feedback resistance
Voh = 10 # # volt #output voltage
Vol = -10 # # volt # output voltage
# upper voltage
V = (R1/(R1+R2)*Voh) #
print ' The upper voltage is = %0.2f'%V,' V '
# Lower voltage
V = (R1/(R1+R2)*Vol) #
print ' The lower voltage is = %0.2f'%V,' V '
```