-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path3-11.py
More file actions
107 lines (85 loc) · 2.38 KB
/
3-11.py
File metadata and controls
107 lines (85 loc) · 2.38 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import collections
def faktorial(x):
a = 1
for i in range(2, x+1):
a *= i
return a
def spisok_faktorial(x):
spisok = [faktorial(x)]
for i in range(x-1, 0, -1):
spisok.append(faktorial(i))
print(spisok)
spisok_faktorial(6)
######################################################
pets = {
1:
{
"Barsik": {
"vid": "kot",
"vozrast": 9,
"vladelec": "Lesha"
},
},
2:
{
"Muhtar": {
"vid": "dog",
"vozrast": 12,
"vladelec": "Sasha"
},
},
}
def get_suffix(age):
suffix = ''
if (age > 4) and (age < 21):
suffix = 'let'
else:
if age%10==1:
suffix = 'god'
elif age%10 < 5:
suffix = 'goda'
else:
suffix = 'let'
return suffix
def create():
last = collections.deque(pets, maxlen=1)[0]
name = input("vvedite imya: ")
vid = input("vvedite vid: ")
age = int(input("vvedite vozrast: "))
pet_owner = input("vvedite imya vladelca: ")
pet = {name:{"vid":vid, "vozrast":age, "vladelec":pet_owner}}
pets[last+1] = pet
def read(x):
pet_name = list(pets[x].keys())[0]
pet_char = list(pets[x].values())
vid = pet_char[0]['vid']
vozrast = pet_char[0]['vozrast']
vladelec = pet_char[0]['vladelec']
print(f'Eto {vid} po klichke "{pet_name}". Vozrast: {vozrast} {get_suffix(vozrast)}. Hozyain: {vladelec}.')
def update(a, b, c):
if b == "vid":
pet_char = list(pets[a].values())
pet_char[0]['vid'] = c
elif b == "vozrast":
pet_char = list(pets[a].values())
pet_char[0]['vozrast'] = c
elif b == "vladelec":
pet_char = list(pets[a].values())
pet_char[0]['vladelec'] = c
def delete(x):
del pets[x]
command = ''
while(command != 'stop'):
command = input("Vvedite create, read, update ili delete: ")
if command == "create":
create()
elif command == "read":
x = int(input("vvedite nomer: "))
read(x)
elif command == "update":
a = int(input("vvedite nomer "))
b = input("chto pomenyat? vid vvozrast vladelec ")
c = input("na chto pomenat? ")
update(a, b, c)
elif command == "delete":
x = int(input("vvedite nomer "))