from math import factorial
# Variables
N1 = 1.
N2 = 1.
N3 = 3.
N4 = 1.
# Calculations
N = N1+N2+N3+N4
sig = factorial(N) /(factorial(N1) *factorial(N2)*factorial(N3)*factorial(N4))
# Results
print "No. of ways of arranging = %d "%(sig)
# Variables
N = 6.
g = 4.
# Calculations
sig = factorial(g+N-1) /(factorial(g-1) *factorial(N))
# Results
print "No. of ways of arranging = %d "%(sig)
from math import factorial
# Variables
N = 6.
g = 8.
# Calculations
sig = factorial(g) /(factorial(N) *factorial(g-N))
# Results
print "No. of ways = %d "%(sig)
%matplotlib inline
import math
from matplotlib.pyplot import bar
# Variables
N0 = 1.
# Calculations
N1 = 3/math.e
N2 = 6/math.e**2
N3 = 10/math.e**3
N = N0+N1+N2+N3
ei = [0, 1, 2, 3]
f0 = N0/N
f1 = N1/N
f2 = N2/N
f3 = N3/N
fi = [f0, f1, f2, f3]
# Results
print "fractional population of level 0 = %.3f"%(f0)
print " fractional population of level 1 = %.3f"%(f1)
print " fractional population of level 2 = %.3f"%(f2)
print " fractional population of level 3 = %.3f"%(f3)
bar(ei,fi,0.1)