-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path32_student_detail_using_dictionary.py
More file actions
312 lines (254 loc) · 7.48 KB
/
Copy path32_student_detail_using_dictionary.py
File metadata and controls
312 lines (254 loc) · 7.48 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
import math
backend = {
"back_1": {
"firstname": "abraham",
"lastname": "adekunle",
"attendance": 12,
"day of birth": 13,
"month of birth": "january",
"height": 180,
"weight": 75,
"age": 25
},
"back_2": {
"firstname": "yussuff",
"lastname": "oyedele",
"attendance": 10,
"day of birth": 21,
"month of birth": "june",
"height": 130,
"weight": 65,
"age": 28
},
"back_3": {
"firstname": "awwal",
"lastname": "adeleke",
"attendance": 9,
"day of birth": 4,
"month of birth": "april",
"height": 240,
"weight": 78,
"age": 27
},
"back_4": {
"firstname": "adebusola",
"lastname": "adeyeye",
"attendance": 12,
"day of birth": 17,
"month of birth": "may",
"height": 200,
"weight": 98,
"age": 29
},
"back_5": {
"firstname": "bashir",
"lastname": "balogun",
"attendance": 8,
"day of birth": 13,
"month of birth": "march",
"height": 170,
"weight": 72,
"age": 24
},
"back_6": {
"firstname": "abdullahi",
"lastname": "salaam",
"attendance": 9,
"day of birth": 30,
"month of birth": "march",
"height": 180,
"weight": 75,
"age": 27
},
"back_7": {
"firstname": "faith",
"lastname": "adeosun",
"attendance": 11,
"day of birth": 25,
"month of birth": "september",
"height": 15,
"weight": 67,
"age": 28
},
"back_8": {
"firstname": "ahmad",
"lastname": "sharaufdeen",
"attendance": 10,
"day of birth": 13,
"month of birth": "november",
"height": 189,
"weight": 79,
"age": 34
},
"back_9": {
"firstname": "lukman",
"lastname": "abisoye",
"attendance": 11,
"day of birth": 21,
"month of birth": "december",
"height": 190,
"weight": 87,
"age": 28
},
"back_10": {
"firstname": "Toluwanimi",
"lastname": "ogunbiyi",
"attendance": 11,
"day of birth": 24,
"month of birth": "november",
"height": 180,
"weight": 75,
"age": 24
},
"back_11": {
"firstname": "Abdulwalii",
"lastname": "Tajudeen",
"attendance": 7,
"day of birth": 17,
"month of birth": "november",
"height": 198,
"weight": 75,
"age": 45
}
}
# return number of people
def population(list):
return (len(list))
# print(population(backend))
# Remove Profile
def remove(data, firstname):
for x in data:
if data[x]["firstname"] == firstname:
del data[x]
return data
# Attendance
def attendance(data, firstname, num):
z = 0
for x in data:
if data[x]["firstname"] == firstname:
z = z + (data[x]["attendance"]) + num
data[x]["attendance"] = z
data[x]["attendance"] += num
return data
# update name
def update_name(data, firstname, lastname, n_first, n_last):
for x in data:
if data[x]['firstname'] == firstname and data[x]['lastname'] == lastname:
data[x]['firstname'] = n_first
data[x]['lastname'] = n_last
return data
# BMI
def bmi(data, firstname):
body = 0
for x in data:
if data[x]['firstname'] == firstname:
body += data[x]['weight'] / ((data[x]['height'] / 100) ** 2)
return body
# max num
def max_number(data):
highest_number = 0
age = []
for x in data:
if True:
age.append(data[x]['age'])
highest_number += 0
for numero in age:
if numero > highest_number:
highest_number = numero
return highest_number
# average
def average(data):
result = 0
age = []
for x in data:
if True:
age.append(data[x]["age"])
result += math.fsum(age) / len(age)
return result
# minimum
def minimum(data):
age = []
for x in data:
age.append(data[x]["age"])
lowest_number = age[0]
for numero in age:
if numero < lowest_number:
lowest_number = numero
return lowest_number
# fullname in titlecase
def titlecase(data, firstname):
for x in data:
if data[x]['firstname'] == firstname:
return (data[x]["firstname"]).title() + ' ' + (data[x]['lastname']).title()
def title(data):
full_name = []
for x in data:
if True:
full_name.append((data[x]["firstname"]).title() + ' ' + (data[x]['lastname']).title())
return full_name
# birthmonth
def birth_month(data, firstname):
for x in data:
if data[x]['firstname'] == firstname:
return data[x]['month of birth']
# initials
def initials(data):
init = []
for x in data:
if True:
a_in = (data[x]["firstname"].upper())[0]
l_in = (data[x]["lastname"].upper())[0]
result = a_in + "." + l_in
init.append(result)
return init
# add profile
def add_profiles(data):
n_data = {}
firstname = input("what is your firstname ? ")
lastname = input("what is your lastname ?")
atten_dance = int(input("input the number of times you were present"))
day_ob = int(input("what is your DAY of birth ?"))
month_ob = input("what is your Month of birth ?")
h_ight = int(input("what is your height ? "))
w_ight = int(input("what is your weight ? "))
age = int(input("what is your age ? "))
n_data['firstname'] = firstname
n_data['lastname'] = lastname
n_data['attendance'] = atten_dance
n_data['day of birth'] = day_ob
n_data['month of birth'] = month_ob
n_data['height'] = h_ight
n_data['weight'] = w_ight
n_data['age'] = age
data.update(n_data)
return data
# print(add_profiles(backend))
# print(backend)
# group profile
def g_profile(data):
first_quarter = []
second_quarter = []
third_quarter = []
fourth_quarter = []
for x in data:
if data[x]['month of birth'] == 'january' or data[x]['month of birth'] == 'february' or data[x][
'month of birth'] == 'march':
first_quarter.append(data[x])
elif data[x]['month of birth'] == 'may' or data[x]['month of birth'] == 'june' or data[x][
'month of birth'] == 'april':
second_quarter.append(data[x])
elif data[x]['month of birth'] == 'july' or data[x]['month of birth'] == 'august' or data[x][
'month of birth'] == 'september':
third_quarter.append(data[x])
elif data[x]['month of birth'] == 'october' or data[x]['month of birth'] == 'november' or data[x][
'month of birth'] == 'december':
fourth_quarter.append(data[x])
groups = first_quarter + second_quarter + third_quarter + fourth_quarter
return groups
print(g_profile(backend))
# birthyear
def birthyear(data, firstname):
for x in data:
if data[x]["firstname"] == firstname:
birth_y = 2022 - (data[x]["age"])
return birth_y