Created
September 3, 2019 11:15
-
-
Save dzervas/33d3d55754310c168e7fe1d7431619b6 to your computer and use it in GitHub Desktop.
E-Food.gr pinata discount calculator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import sys | |
# Usage: python efood_pinata.py 5 5 5 3 | |
items = sys.argv[1:] | |
total = 0 | |
discountp = 0 | |
for i in items: | |
total += float(i) | |
if total >= 30: | |
discountp = (20/30) | |
print(f"Hit 30€ pinata: -{discountp * 100:.2f}% ") | |
elif total >= 20: | |
discountp = (15/20) | |
print(f"Hit 20€ pinata: -{discountp * 100:.2f}% ") | |
elif total >= 15: | |
discountp = (10/15) | |
print(f"Hit 15€ pinata: -{discountp * 100:.2f}% ") | |
print(f"Total: {total:.2f}€ Saved: {total - (discountp * total):.2f}€") | |
for i in items: | |
print(f"Item {i}€ -> {float(i) * discountp:.2f}€") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Oh yes, here