Answers for "Write a code with function getFare(String Source, String Destination) which take Input as source and destination stops(in the format containing first two characters of the Name of the Bus Stop) and calculate and return travel fare."

0

Write a code with function getFare(String Source, String Destination) which take Input as source and destination stops(in the format containing first two characters of the Name of the Bus Stop) and calculate and return travel fare.

BusStops = [ "TH", "GA", "IC", "HA", "TE", "LU", "NI","CA" ]
Path = [800, 600, 750, 900, 1400, 1200, 1100, 1500]

s, d = input(), input()

if s not in BusStops or d not in BusStops:
    print("INVALID OUTPUT")
else:
    dist =sum(Path[BusStops.index(s):BusStops.index(d) + 1])
    cost = dist * 0.005
    if cost >= 5:
        print(cost, " INR")
    else:
        print("5 INR")
Posted by: Guest on June-12-2021

Code answers related to "Write a code with function getFare(String Source, String Destination) which take Input as source and destination stops(in the format containing first two characters of the Name of the Bus Stop) and calculate and return travel fare."

Python Answers by Framework

Browse Popular Code Answers by Language