Answer to Question #308948 in Python for Michael

Question #308948

There are N intermediate stations between two places A and B. Find the number of ways in which a train can be made to stop at S number of these intermediate stations so that no two stopping stations are consecutive. Write a python module Station.py for above and import the module in RollNo_W12B_3.py. In RollNo_W12B_3.py, define a function Get_Stations(N, S)  which takes value of N & S and return integer result as shown in example by calling the appropriate function implemented in Station.py module. Also handle the possible exceptions and display the exception message in form of string.


Example-1

Example-2

Example-3

Input:

12

4

 

Output:

126

Input:

16

5

 

Output:

792

Input:

2

4

 

Output:



1
Expert's answer
2022-03-12T18:05:47-0500
import math
def Get_Station(N, S):
    n = N - S + 1
    sol = math.factorial(n)/(math.factorial(S) * math.factorial(n-S)) 
    return sol



Get_Station(12, 4)
126.0

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS