# Untitled unknown
plain_text
2 months ago
1.8 kB
0
Indexable
Never
```# User Input
number_of_trips = int(input("Number of Trips: "))

for num in range(number_of_trips):
day_type = int(input("Day Type (1 = Weekdays, 2 = Weekends/PH): ")) # surcharge
boarding_time = int(input("Boarding hour and minute: ")) # surcharge
total_distance = int(input("Distance travelled: "))

# Weekdays and Weekends/PH
weekdays = 1
weekends = 2
PH = 2

# Determine basic condition
basic_distance = 1000
flag_down = 3.90
surcharge = 0

# Determine surcharge time range
midnight = range(0000, 600)
morning_peak_hour = range(600, 930)
evening_peak_hour = range(1800, 2360)

if total_distance <= basic_distance: # distance less than or equal to 1km
basic_fare = 3.90
else: # calculate the charge of additional distance
distance_charge = (additional_distance / 400) * 0.22
basic_fare = flag_down + distance_charge

if boarding_time in midnight: # Midnight surcharge
surcharge = 0.5 * basic_fare
total_fare = basic_fare + surcharge
print("Total fare: \$", total_fare)
elif boarding_time in morning_peak_hour:
if day_type == weekdays: # Morning surcharge
surcharge = 0.25 * basic_fare
total_fare = basic_fare + surcharge
print("Total fare: \$", total_fare)
else: # No surcharge
total_fare = basic_fare
print("Total fare: \$", total_fare)
elif boarding_time in evening_peak_hour: # Evening surcharge
surcharge = 0.25 * basic_fare
total_fare = basic_fare + surcharge
print("Total fare: \$", total_fare)
else: # No surcharge
total_fare = basic_fare
print("Total fare: \$", total_fare) ```