Chapter1 - Set Theory¶

Ex1.7 Pg 9¶

In [1]:
print 'To find : number of mathematics students taking atleast one of the languages French(F),German(G) and Russian(R)'
F=65# #number of students studying French
G=45#  # number of students studying German
R=42#  #number of students studying Russian
FandG=20#  #number of students studying French and German
FandR=25#  #number of students studying French and Russian
GandR=15#   #number of students studying German and Russian
FandGandR=8# #number of students studying French,German and Russian
#By inclusion-exclusion principle
ForGorR=F+G+R-FandG-FandR-GandR+FandGandR#
print 'the number of students studying atleast one of the languages :',ForGorR

To find : number of mathematics students taking atleast one of the languages French(F),German(G) and Russian(R)
the number of students studying atleast one of the languages : 100


Ex1.8 Pg 10¶

In [2]:
print 'In a college, 120 mathematics students can opt for either French(F),German(G) or Russian(R)'
n=120#  #total number of students
F=65#  #number of students studying French
G=45#  #number of students studying German
R=42#  #number of students studying Russian
FandG=20#  #number of students studying French and German
FandR=25#  #number of students studying French and Russian
GandR=15#  #number of students studying German and Russian
FandGandR=8#  #number of students studying French,German and Russian
print 'using inclusion-exclusion principle:'
ForGorR=F+G+R-FandG-FandR-GandR+FandGandR#
print 'number of students studying French or German or Russian',ForGorR
FGnR=FandG-FandGandR#
print 'number of students studying French and German but not Russian',FGnR
FRnG=FandR-FandGandR #
print 'number of students studying French and Russian but not German',FRnG
GRnF=GandR-FandGandR #
print 'number of students studying German and Russian but not French',GRnF
OF=F-FGnR-FandGandR-FRnG #
print 'number of students studying  Only French',OF
OG=G-FGnR-FandGandR-GRnF#
print 'number of students studying  Only German',OG
OR=R-FRnG-FandGandR-GRnF#
print 'number of students studying  Only Russian',OR
k=n-ForGorR#
print 'number of students not studying any of the languages',k

In a college, 120 mathematics students can opt for either French(F),German(G) or Russian(R)
using inclusion-exclusion principle:
number of students studying French or German or Russian 100
number of students studying French and German but not Russian 12
number of students studying French and Russian but not German 17
number of students studying German and Russian but not French 7
number of students studying  Only French 28
number of students studying  Only German 18
number of students studying  Only Russian 10
number of students not studying any of the languages 20


Ex1.13 Pg 12¶

In [3]:
x=10# #number of members of set X
P=2**x #number of members of the power set of X
q=P-1##x itself is not the proper subset.Hence it isn't counted
print 'number of members of powerset P which are proper subsets of x are:',q

number of members of powerset P which are proper subsets of x are: 1023


Ex1.14 Pg 12¶

In [4]:
A=[1,2,3,4,5]#  #eatables for salad preparation 1=onion,2=tomato,3=carrot,4=cabbage,5=cucumber
p=len(A)#   #total number of eatables available
n=2**p-1#  #no salad can be made without atleast one of the eatables.Hence null set isn't counted
print 'number of different salads that can be prepared using the given eatables',n

number of different salads that can be prepared using the given eatables 31


Ex1.18 Pg 13¶

In [5]:
U1=1#  #given
U2=5#  #given
P=[]#
for I in range(0,2):
i=I+1
P.append(3**i-2**i)
print "P(%s)"%(i),P[I]
print 'P(1)=U(1) and P(2)=U(2)'#
print 'hence Un=3**n-2**n for all n belonging to N'

P(1) 1
P(2) 5
P(1)=U(1) and P(2)=U(2)
hence Un=3**n-2**n for all n belonging to N