Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.3 kB
0
Indexable
Never
number_trips = int(input("Enter the number of trip :" ))

for num in range(number_trips):
    day_type = int(input("Enter the day type as 1 for weekday, 2 for weekend/PH :"))
    boarding_time = input("Enter boarding time in 24-hour format (hhmm) : ")
    distance_traveled = int(input("Enter distance traveled in meter : "))

    flag_down = 3.90
    basic_distance = 1000
    
    # Define constants of the day type
    weekday = 1
    weekend_PH = 2
    
    # Determine the time range of surcharge
    midnight = range(0, 600)
    morning_peak_hour = range(600, 930)
    evening_peak_hour = range(1800, 2360)
    
    # Calculate the additional distance charge
    if  distance_traveled <= basic_distance:
        basic_fare = flag_down 
    else:
        additional_distance = distance_traveled - basic_distance
        distance_charge = (additional_distance/ 400) * 0.22
        basic_fare = flag_down + distance_charge
    
    # Calculate the surcharge
    surcharge = 0
    if boarding_time in midnight:
        surcharge = 0.5 * basic_fare 
    elif boarding_time in morning_peak_hour and day_type == 1 or boarding_time in evening_peak_hour:
        surcharge = 0.25 * basic_fare
        
    # Calculate the total fare
    total_fare = basic_fare + surcharge

    # Print the result
    print("Total fare's $" , total_fare)