1---
2version: 0.1.0
3precision: 2
4form_title: Public Transport vs Car
5form_description: Compare the cost of public transport vs driving. Enter distances, ticket prices and car costs to see which is cheaper.
6form_inputs: One-way distance|distance{km}, Fuel consumption|consumption{L/100km}, Fuel price|fuel_price{€/L}, Parking|parking{€}, Single ticket|ticket_single{€}, Monthly pass|pass_monthly{€}, Trips per month|trips{}
7form_outputs: Car cost per trip|car_trip, PT cost per trip|pt_trip, Monthly car cost|car_month, Monthly PT cost|pt_month, Savings|savings
8---
9# draftply – Public Transport vs Car
10# Which is cheaper for your commute?
11
12# ── Parameters ──────────────────────────────────────────
13distance = 15 km # one-way distance
14trips = 20 trips/mo # trips per month (each way counts)
15
16# Car costs
17consumption = 7 L/100km
18fuel_price = 1.80 €/L
19parking = 2 € # parking cost per trip
20
21# Public transport costs
22ticket_single = 3.50 € # single ticket price
23pass_monthly = 60 € # monthly pass price
24
25# ── Cost calculations ──────────────────────────────────
26# Car: round trip fuel cost + parking
27fuel_per_trip = distance * 2 * consumption
28car_fuel_cost = fuel_per_trip * fuel_price
29car_parking_cost = parking
30car_trip = car_fuel_cost + car_parking_cost
31
32# Monthly car cost
33car_month = car_trip * trips
34
35# Public transport: which is cheaper, single tickets or pass?
36pt_trip = ticket_single
37pt_single_month = pt_trip * trips
38pt_month_cost = min(pt_single_month, pass_monthly)
39
40# If using pass, how many trips to break even?
41pass_break_even = pass_monthly / ticket_single
42
43# Savings (positive if PT is cheaper)
44savings = car_month - pt_month_cost
45savings_percent = (savings / car_month) * 100
46
47# CO2 comparison (car vs PT, PT assumed 50g CO2/km for bus)
48co2_car = distance * 2 * 2.31 kg/L * consumption # kg CO2 per round trip
49co2_pt = distance * 2 * 0.05 kg/km # kg CO2 per round trip
50co2_savings = co2_car - co2_pt
51
52# ── Results ─────────────────────────────────────────────
53"One-way distance": distance
54"Trips per month": trips
55
56"Car cost per round trip": car_trip
57"PT cost per trip": pt_trip
58
59"Monthly car cost": car_month
60"Monthly PT cost": pt_month_cost
61
62"Cheaper option": "Public transport" if savings > 0 else "Car"
63"Monthly savings": savings
64"Savings percentage": savings_percent
65
66"CO2 per trip (car)": co2_car
67"CO2 per trip (PT)": co2_pt
68"CO2 saved per trip": co2_savings
69
70"Pass break-even at": pass_break_even trips
71