# ，因为我想

2017-09-16 154 views
0
``````num = input ("Please enter an amount in euros:")
x = int (num)
print (x)
a = x // 500 # The operations are performed to find how many bills of each heat there is and its residue.
x = x% 500
if not a == 0: # Condition for the value of agreement only in the result of the residue in case none exists.
b = x // 200
x = x% 200
else: b = x // 200
yes no b == 0:
c = x // 100
x = x% 100
else: c = x // 100
if not c == 0:
d = x // 50
x = x% 50
else: d = x // 50
if not d == 0:
e = x // 20
x = x% 20
else: e = x // 20
if it is not e == 0:
f = x/10
x = x% 10
else: f = x // 10
if not f == 0:
g = x // 5
x = x% 5
else: g = x // 5 # I make several conditions that allow me
if not g == 0: #Evaluate the results of each operation
h = x // 2 # immediately above.
x = x% 2
else: h = x // 2
if not h == 0:
i = x // 1
x = x% 1
else: i = x // 1

print ("There", a, "500 euro banknote (s)")
print ("There", b, "ticket (s) of 200 euros")
print ("There", c, "ticket (s) of 100 euros")
print ("There", d, "50 euro banknote (s)") # printout of results
print ("There", and, "ticket (s) of 20 euros")
print ("There", f, "ticket (s) of 10 euros")
print ("There", g, "ticket (s) of 5 euros")
print ("There", h, "currency (s) of 2 euros")
print ("There", i, "currency (s) of 1 euros")
``````

+0

## 回答

0

``````num = int(input("Please enter an amount in euros: "))

banknotes = {
500: "500 euro banknote (s)",
200: "ticket (s) of 200 euros",
100: "ticket (s) of 100 euros",
50: "50 euro banknote (s)",
20: "ticket (s) of 20 euros",
10: "ticket (s) of 10 euros",
5: "ticket (s) of 5 euros",
2: "currency (s) of 2 euros",
1: "currency (s) of 1 euros"
}

while num:
max_banknote = max(list(filter(lambda y: y <= num, banknotes)))

count = num // max_banknote
num -= count*max_banknote
print("There", count, banknotes[max_banknote])
``````