Write a python program to calculate the fare and discount for the passengers travelling in a bus. When a Passenger enters the bus, the program, will determine the traveling kilometer knowing distance from passenger (as an approximate integer) the conductor mentions the fare to the passenger according to following criteria below using control structure in python code.The program will also calculate the passenger 20% discount for students ,PWD and senior citizen passenger.
5KM- 25.00
5-10KM – 30.00
10-30KM – 50.00
30-50KM -100.00
50-80KM – 150.00
80-100KM – 250.00
def generate_ticket(airline,source,destination,no_of_passengers):
ticket_number_list = []
i = 0
if no_of_passengers < 5:
while no_of_passengers != 0:
ticket_number_list.append(airline + ":" + source[:3] + ":" + destination[:3] + ":" + str(101+i))
i = i+1
no_of_passengers = no_of_passengers - 1
else:
for i in range(5):
ticket_number_list.append(airline + ":" + source[:3] + ":" + destination[:3] + ":" + str(100+no_of_passengers))
i = i+1
no_of_passengers = no_of_passengers - 1
ticket_number_list = ticket_number_list[::-1]
return ticket_number_list
#Provide different values for airline,source,destination,no_of_passengers and test your program
print(generate_ticket("AI","Bangalore","London",7))
Comments
Leave a comment