#!/usr/bin/env python3
|
|
#title :FA-1.py
|
|
#description :Final Assignemt: NS Functies
|
|
#author :Marcel Haazen
|
|
#email :marcel@haazen.xyz
|
|
#date :23-09-2019 - 11:53
|
|
#edit_date :27-09-2019 - 23:25
|
|
#version :0.1
|
|
#usage :python3 FA-1.py
|
|
#notes :Sorry als het wat gehaast is, en laat heb het snel gemaakt vanuit bed me bijholteontsteking dus wou het snel maken
|
|
#python_version :3.7.4
|
|
#==============================================================================
|
|
|
|
def standaardtarief(afstandKM):
|
|
price = 0.0
|
|
if afstandKM <0:
|
|
# If distance is negative or 0 the price is also 0
|
|
return 0.0
|
|
elif afstandKM > 50:
|
|
# As of 50 KM the price per KM gets decreased to 60 cents bet gets a base price of 15 euro on top
|
|
price = round(15.0 + (afstandKM * 0.6), 2)
|
|
return price
|
|
else:
|
|
# Calculate price per KM based on 80 cents per KM and no base price
|
|
price = round(afstandKM * 0.8, 2)
|
|
return price
|
|
|
|
def ritprijs(leeftijd,weekendrit,afstandKM):
|
|
basis = standaardtarief(afstandKM)
|
|
if weekendrit == True:
|
|
if leeftijd < 12 or leeftijd >= 65:
|
|
prijs = basis*0.65
|
|
else:
|
|
prijs = basis*0.6
|
|
else:
|
|
if leeftijd < 12 or leeftijd >= 65:
|
|
prijs = basis*0.7
|
|
else:
|
|
prijs = basis
|
|
return round(prijs,2)
|
|
|
|
|
|
print(ritprijs(11,True,14))
|
|
print(ritprijs(12,True,14))
|
|
print(ritprijs(64,True,14))
|
|
print(ritprijs(65,True,14))
|
|
|
|
print(ritprijs(11,False,14))
|
|
print(ritprijs(12,False,14))
|
|
print(ritprijs(64,False,14))
|
|
print(ritprijs(65,False,14))
|
|
|
|
print(ritprijs(11,True,51))
|
|
print(ritprijs(12,True,51))
|
|
print(ritprijs(64,True,51))
|
|
print(ritprijs(65,True,51))
|
|
|
|
print(ritprijs(11,False,51))
|
|
print(ritprijs(12,False,51))
|
|
print(ritprijs(64,False,51))
|
|
print(ritprijs(65,False,51))
|