In [20]:

```
#Variable declaration
NO=0.0542 #equilibrium conc of NO, M
O2=0.127 #equilibrium conc of O2, M
NO2=15.5 #equilibrium conc of NO2, M
#Calculation
Kc=NO2**2/(O2*NO**2) #equilibrium constant for given reaction
#Result
print"The value of the equilibrium constant of the reaction is %.2e"%Kc
```

In [5]:

```
#Variable declaration
PCl3=0.463 #equilibrium pressure of PCl3, atm
PCl5=0.875 #equilibrium pressure of PCl5, atm
Kp=1.05 #equilibrium constant of the reaction
#Calculation
Cl2=Kp*PCl5/PCl3 #equilibrium pressure of Cl2 in atm, formula from the definition of equilibrium constant
#Result
print"The value of the equilibrium pressure of the Cl2 gas is :",round(Cl2,2),"atm"
```

In [6]:

```
#Variable declaration
Kc=10.5
delta_n=1-3
T=273+220
#Calculation
Kp=Kc*(0.0821*T)**delta_n
#Result
print"The value of the equilibrium constant of the reaction is :%.2e"%Kp
```

In [7]:

```
#Variable declaration
CO2=0.236 #pressure of CO2 gas, atm
T=273+800
#Calculation
#(a)
Kp=CO2
#(b)
delta_n=1
Kc=Kp*(0.0821*T)**-delta_n
#Result
print"(a) the value of Kp of the reaction is :",Kp
print"(b) the value of Kc of the reaction is %.2e"%Kc
```

In [8]:

```
#Variable declaration
Kc=1.2 #equilibrium constant for the reaction
N2=.249/3.5 #conc of N2, M
H2=(3.21*10**-2)/3.5 #conc of H2, M
NH3=(6.42*10**-4)/3.5 #conc of NH3, M
#Calculation
Qc=NH3**2/(N2*H2**3) #reaction quotient initial
print"Qc=",round(Qc,3),"(approx)"
#Result
if(Qc==Kc):
d="the system is in equilibrium"
elif(Qc<Kc):
d="the system is not in equilibrium and the reaction will move from left to right"
else:
d="the system is not in equilibrium and the reaction will move from right to left"
print d
```

In [13]:

```
#Variable declaration
Kc=54.3
H2i=0.5 #initial moles of H2
I2i=0.5 #initial moles of I2
#Calculation
#Let us assume that x moles have reacted, so, HI=2x, H2=0.5-x, I2=0.5-x, when we substitute in Kc=(HI)**2/(H2)*(I2) we get 54.3=(2x)**2/((0.5-x)*(0.5-x)) taking root we get 7.37=2*x/0.5-x
x=0.393 #from the above equation
H2=0.5-x
I2=0.5-x
HI=2*x
#Result
print"The equilibrium concentration of H2 is :",H2,"M"
print"The equilibrium concentration of I2 is :",I2,"M"
print"The equilibrium concentration of HI is :",HI,"M"
```

In [9]:

```
import math
#Variable declaration
Kc=54.3
HIo=0.0224
H2o=0.00623
I2o=0.00414
#let us assume that x moles have reacted, so, HI=HIo+2x, H2=0.00623-x, I2=0.00414-x, when we substitute in Kc=(HI)**2/(H2)*(I2) we get 54.3=(2x+0.0224)**2/((0.00623-x)*(0.00414-x)) simplifying we get 50.3x**2-0.654x+8.98*10**-4=0
a=50.3
b=-0.654
c=8.98*10**-4
#Calculation
x1=(-b+math.sqrt(b**2-4*a*c))/(2*a)
x2=(-b-math.sqrt(b**2-4*a*c))/(2*a)
if(x1>I2o):
x=x2
else:
x=x1
H2=0.00623-x
I2=0.00414-x
HI=2*x+0.0224
#Result
print"The equilibrium concentration of H2 is :",round(H2,5),"M"
print"The equilibrium concentration of I2 is :",round(I2,5),"M"
print"The equilibrium concentration of HI is :",round(HI,4),"M"
```

In [3]:

```
#Variable declaration
Kc=2.37*10**-3 #equilibrium constant for the reaction
N2=0.683 #conc of N2, M
H2=8.8 #conc of H2, M
NH3=3.65 #conc of NH3, M
#Calculation
Qc=NH3**2/(N2*H2**3) #reaction quotient initial
print"Qc=%.2e"%Qc
#Result
if(Qc==Kc):
d="the system is in equilibrium"
elif(Qc<Kc):
d="the system is not in equilibrium and the reaction will move from left to right"
else:
d="the system is not in equilibrium and the reaction will move from right to left"
print d
```