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
```

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 [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
```

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
```

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'
```