Link to the source from the official Vélib website
The total price is broken down in two parts. The first part is a fixed cost that you pay for a one year subscription to the service. The second part comes from a charge that you pay for each bicycle rental, with a hunch: the first 30 (standard contract) or 45 minutes ("Passion" contract) are free of charge while the following half-hours each have an increasing cost. You pay:
Let's see what this looks like graphically.
def cost(travel_time, passion=False):
""" returns cost of a Vélib rental as a function of travel time in minutes
and whether the user has subscribed to the "Passion" offer"""
cost = 0
if passion:
free_time = 45
else:
free_time = 30
remaining_time = travel_time - free_time
if remaining_time >= 0:
n = int(remaining_time) / 30 + 1
cost = (n >= 1) * 1 + (n >= 2) * 2 + (n >=3) * (n - 2) * 4
else:
cost = 0
return cost
for i in [15, 30, 45, 60, 89, 90]:
print "cost of %i minutes is %i €" % (i, cost(i))
cost of 15 minutes is 0 € cost of 30 minutes is 1 € cost of 45 minutes is 1 € cost of 60 minutes is 3 € cost of 89 minutes is 3 € cost of 90 minutes is 7 €
minutes = arange(0, 250, 1)
costs = map(cost, minutes)
plot(minutes / 30., costs)
grid(True)
xlabel(u"half hours travelled with a Vélib")
ylabel(u"cost in €")
<matplotlib.text.Text at 0x62666b0>