Answer to Question #309045 in Python for Munna

Question #309045

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 main program .In main program define a function Get-Station(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. Do not use input function provide input in fixed form.


For Example : 1) Input : N= 12 , S= 4

Output: 126


2) Input : N= 2 , S = 4

Output : 0



1
Expert's answer
2022-03-10T18:08:08-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(16, 5)
792.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