In [2]:

```
#initiation of variable
from math import log
N2=0.25;N1=0.75; #various given values
L2=1.0;L1=0.0;
E1_E2=-4.7*(10**-4); #Energy difference
#calculation
a=(N2/N1); b=(((2*L2)+1)/((2*L1)+1));c=E1_E2; #various terms involved in the formula of ratio of population
kT=(c/log(a/b)); #value of k*T
k=0.0000856; #constant
T=kT/k; #temperature of interstellar space
#result
print "The temperature of interstellar space was found out to be in K",round(T,3);
```

In [1]:

```
#initiation of variable
mc2=940.0*10**6; k=8.6*10**-5; #various constants and given values in suitable units
#calculation
T= mc2/k; #temperature of the photons
#result
print "The temperature of the photons must be in K %.1e" %round(T,3);
#part2
t=((1.5*10**10)/T)**2; #age of universe when the photons have the above temperature
#result
print"The age of the universe for the temperature of the photon to be as obtained above in seconds is %.01e" %t;
```

In [6]:

```
#initation of variable
from math import exp
k=8.62*10**-5; #various values and constants
T= 1.5*10**10;
delE=1.3*10**6;
#calculation
a= delE/(k*T); #exponent in boltzmann factor
b=exp(-a); #ratio of neutron to protons
r=(1/(1+b))*100; #relative number of protons
#result
print"The percentage of protons is",round(r)," neutrons is ",round(100-r);
```