You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.8 KiB

пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
пре 5 година
  1. #!/usr/bin/env python3
  2. #title :FA-1.py
  3. #description :Final Assignemt: NS Functies
  4. #author :Marcel Haazen
  5. #email :marcel@haazen.xyz
  6. #date :23-09-2019 - 11:53
  7. #edit_date :27-09-2019 - 23:25
  8. #version :0.1
  9. #usage :python3 FA-1.py
  10. #notes :Sorry als het wat gehaast is, en laat heb het snel gemaakt vanuit bed me bijholteontsteking dus wou het snel maken
  11. #python_version :3.7.4
  12. #==============================================================================
  13. def standaardtarief(afstandKM):
  14. price = 0.0
  15. if afstandKM <0:
  16. # If distance is negative or 0 the price is also 0
  17. return 0.0
  18. elif afstandKM > 50:
  19. # As of 50 KM the price per KM gets decreased to 60 cents bet gets a base price of 15 euro on top
  20. price = round(15.0 + (afstandKM * 0.6), 2)
  21. return price
  22. else:
  23. # Calculate price per KM based on 80 cents per KM and no base price
  24. price = round(afstandKM * 0.8, 2)
  25. return price
  26. def ritprijs(leeftijd,weekendrit,afstandKM):
  27. basis = standaardtarief(afstandKM)
  28. if weekendrit == True:
  29. if leeftijd < 12 or leeftijd >= 65:
  30. prijs = basis*0.65
  31. else:
  32. prijs = basis*0.6
  33. else:
  34. if leeftijd < 12 or leeftijd >= 65:
  35. prijs = basis*0.7
  36. else:
  37. prijs = basis
  38. return round(prijs,2)
  39. print(ritprijs(11,True,14))
  40. print(ritprijs(12,True,14))
  41. print(ritprijs(64,True,14))
  42. print(ritprijs(65,True,14))
  43. print(ritprijs(11,False,14))
  44. print(ritprijs(12,False,14))
  45. print(ritprijs(64,False,14))
  46. print(ritprijs(65,False,14))
  47. print(ritprijs(11,True,51))
  48. print(ritprijs(12,True,51))
  49. print(ritprijs(64,True,51))
  50. print(ritprijs(65,True,51))
  51. print(ritprijs(11,False,51))
  52. print(ritprijs(12,False,51))
  53. print(ritprijs(64,False,51))
  54. print(ritprijs(65,False,51))