-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcount-debt.py
61 lines (40 loc) · 1.65 KB
/
count-debt.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/python3
# Script for counting money for ascii Dresden.
# This is fairly well written python. One of my first little projects.
name = "MyName"
# Array that contains the values of rows.
staggering = [1.5, 1, .8, .5, .2, .1]
# Arrays for amounts of the bills and coins.
amounts = {coin: 0 for coin in staggering}
"""
Integers for money amount.
```total``` is the sum of all the money in the register.
"""
total = 0
def read_input(amounts: list):
"""Reads the input for the amount of bills and coins in the register."""
for coin in staggering:
try:
amounts[coin] = int(input('Amount of {:1.2f}€: '.format(coin)))
except ValueError:
pass
print(' {:1.2f}€ × {:2d} = {:5.2f}€'.format(coin, amounts[coin],
coin * amounts[coin]))
read_input(amounts)
# Calculate coin amount value
for coin in staggering:
total += amounts[coin] * coin
total = round(total, 2)
headings = [*map(lambda x: "{:1.2f}€".format(x), reversed(staggering)), " Summe "]
values = [
*map(lambda x: "{:5d}".format(x), reversed(amounts.values())),
"{:5.2f}€ ".format(total)
]
print("\nValues for table:")
print("┌─{}─┐".format("─┬─".join(map(lambda x: "─" * len(x), values))))
print("│ {} |".format(" │ ".join(headings)))
print("├─{}─┤".format("─┼─".join(map(lambda x: "─" * len(x), values))))
print("│ {} |".format(" │ ".join(values)))
print("└─{}─┘".format("─┴─".join(map(lambda x: "─" * len(x), values))))
print("Check these again, to be sure you didn't make a typo.\n")
print("Sum: {:1.2f}€".format(total))