In [1]:

```
n=2 #number of employees
r=12 #number of office rooms
ways_alloc_sanchez=12
ways_alloc_patel=11
#By PRODUCT RULE
print "Total ways to assign offices to these employees is",ways_alloc_sanchez*ways_alloc_patel
```

In [2]:

```
alphabets=26 #Total number of alphabets
posint=100 #Total positive numbers not beyond 100
#number of chairs to be labelled with a alphabet and an integer using product rule
print "Total number of chairs that can be labelled with an alphabet and an integer is",alphabets*posint
```

In [3]:

```
mc=32 #total number of microcomputers
port=24 #total number of ports in each microcomputer
#total number of different ports to a microcomputer in the center are found using product rule
print "total number of ports",mc*port
```

In [4]:

```
bits=2 #possible bits either 0 or 1
ns=7 #number of bits in the string (ie). length of the string
# 7 bits are capable of taking either 0 or 1 so by PRODUCT RULE
print "Total different bit strings of lenth seven are",bits**ns
```

In [7]:

```
letters=26 #number of letters in english alphabet
no_of_letters=3 #number of letters
choices=10 #number of choices for each letter
result=1#in order to avoid junk values. Assigned it to 1.
for i in range(0,no_of_letters):
result=result*letters*choices
print "The total number of choices are",result
```

In [10]:

```
def permutation(n,r): #function definition
i=n
result=1
for i in range((n-r)+1,n+1): #computing the permutation
result=result*i
return result
print "The number of ways to select 3 students from a group of 5 students to line up for a picture is ",permutation(5,3) #function call
print "The number of ways to select 5 students from a group of 5 students to line up for a picture is ",permutation(5,5) #function call
```

In [1]:

```
def permutation(n,r): #function definition
i=n
result=1
for i in range((n-r)+1,n+1): #permutation computation
result=result*i
return result
num=input("Enter the number of people")
perm=input("Enter the prizes")
print "The number of ways to decide the prize winners is",permutation(num,perm) #function call
```

In [2]:

```
def permutation(n,r):
i=n
result=1
for i in range((n-r)+1,n+1):
result=result*i
return result
num=input("Enter the number of runners")
perm=input("Enter the number of prizes")
print "The number of ways to decide the prize winners is",permutation(num,perm)
```

In [3]:

```
def calc(n):
i=n
result=1
for i in range(1,n): #find the number of ways to decide the path. since the first city us decided. The for loop is from 1 to n
result=result*i
return result
num=input("Enter the number of cities")
print "The number of possible ways to decide the path is",calc(num)
```

In [5]:

```
def combination(n,r): #combination function
i=n
numerator=1
denominator=1
for i in range((n-r)+1,n+1):#computes the value of the numerator
numerator=numerator*i
for j in range (1,r+1): #computes the value of the denominator
denominator=denominator*j
result=numerator/denominator #computes result
return result
num=input("Enter the number of elements")
comb=input("Enter the combinations")
print "The number of combinations are ",combination(num,comb)
```

In [7]:

```
def combination(n,r): #function definition for combination
i=n
numerator=1
denominator=1
for i in range((n-r)+1,n+1):
numerator=numerator*i
for j in range (1,r+1):
denominator=denominator*j
result=numerator/denominator
return result
num=input("Enter the number of members in a team")
comb=input("Enter the number of players")
print "The number of combinations are ",combination(num,comb) #function call
```

In [8]:

```
def combination(n,r): #function definition
i=n
numerator=1
denominator=1
for i in range((n-r)+1,n+1):
numerator=numerator*i
for j in range (1,r+1):
denominator=denominator*j
result=numerator/denominator
return result
num=input("Enter the total number of astronauts")
comb=input("Enter the number of astronauts to be selected ")
print "The total number of combinations of selected astronauts to Mars are ",combination(num,comb) #function call
```

In [9]:

```
def combination(n,r): #Function definition
i=n
numerator=1
denominator=1
for i in range((n-r)+1,n+1): #computation of the numerator
numerator=numerator*i
for j in range (1,r+1): #computation of the denominator
denominator=denominator*j
result=numerator/denominator
return result
num1=input("Enter the total number of faculty in computer science department")
comb1=input("Enter the number of faculty to be selected for computer science department")
num2=input("Enter the total number of faculty in maths department")
comb2=input("Enter the number of faculty to be selected for maths department")
print "The total number of combinations of selected faculties are ",combination(num1,comb1)*combination(num2,comb2) #Function call
```