## Find degrees of freedom of a system of two components
c = 2 ## number of components
print("\n Example 7.1")
for n in range (1,4):
p = (c-1.) +2. ## Total variables
f = c-n+2. ## degree of freedom
print'%s %.2f %s %.2f %s'%("\n\n Degree of freedom for two components when \n number of phases is ",n," is ",f,"")
#it is same for other values
## Find minimum number of component in system
p = 4. ## number of phases of system
f = 0. ## number of degree of system
print("\n Example 7.2")
C = f+p-1. ## components number
print'%s %.2f %s '%("\n Minimum number of components in system is ",C,"")
## Calculate amount of pure water that can be extracted from sea water
L = 23.3 ## % composition of L
a = 3.5 ## concentration of Nacl in sea water
ice = 0. ## % composition of ice
print("\n Example 7.3")
f_ice = (L-a)/(L-ice)
print'%s %.2f %s '%("\n Fractional amount of pure water that can be extracted from sea water is ",f_ice,"")
## Calculate proeutectoid ferrite and eutectoid ferrite in 0.6% steel
import math
a = 0 ## limiting value
b = 0.8 ## limiting value
c = 0.6 ## percentage composition of carbon
f = 0.88 ## fraction of ferrite in a eutectoid steel
print("\n Example 7.5")
f_pro_alpha = (b-c)/(b-a)
f_perlite = 1 - f_pro_alpha
f_eut = f*f_perlite
print'%s %.2f %s '%("\n Composition of proeutectoid ferrite is ",f_perlite,"")
print'%s %.2f %s '%("\n Composition of eutectoid ferrite is ",f_eut,"")