class Beer def __init__ self name my_cost buyer_cost balance self _nam

 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
class Beer():
def __init__(self, name, my_cost, buyer_cost, balance):
self._name = name
self._my_cost = my_cost
self._buyer_cost = buyer_cost
self._balance = balance
def info(self):
print(self._name, '-', self._buyer_cost, 'р/л.', '[', self._balance * self._buyer_cost, '/',
self._balance * self._my_cost, ']')
def __str__(self):
return self._name
def sum_beer(b):
for keys, values in b.items():
print(keys, end = ' ')
values.info()
sum = 0
for values in b.values():
sum += values._my_cost * values._balance
print('Итого', sum)
def list_for_order(b):
for keys, values in b.items():
print(keys, values)
bad = Beer('Баденберг', 75, 118, 50)
nem_prem = Beer('Немецкое премиум', 78, 118, 50)
arb = Beer ('Арбуз', 35, 60, 50)
ghig = Beer('Жигулевское', 55, 98, 50)
mayer = Beer('Маер', 55, 97, 50)
slad = Beer('Сладовар', 78, 120, 50)
beer = {
1: bad,
2: nem_prem,
3: arb,
4: ghig,
5: mayer,
6: slad,
}
list_for_order(beer)
n = [int(i) for i in input('Введите через пробел номера пива для формирования заказа.').split()]
print(n)
sum = 0
for i in n:
print(beer[i], beer[i]._my_cost * beer[i]._balance)
sum += beer[i]._my_cost * beer[i]._balance
print(sum)