-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathf_500.py
5521 lines (3992 loc) · 149 KB
/
f_500.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
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
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# This is a set of 500 pieces python functions
from collections.abc import Sequence
from math import pi
# 001
# adding two numbers
def add_num(a, b):
return a + b
assert add_num(2, 5) == 7
# 002
# subtracting two numbers
def subtract_num(a, b):
return a - b
assert subtract_num(2, 5) == -3
# 003
# multiplying two numbers
def multiply_num(a, b):
return a * b
assert multiply_num(2, 5) == 10
# 004
# dividing two numbers
def divide_num(a, b):
return a / b
assert divide_num(2, 5) == 0.4
# 005
# subtracting two numbers without the rest
def divide_num_without_rest(a, b):
return a // b
assert divide_num_without_rest(2, 5) == 0
# 006
# exponentiation of two numbers
def exponentiation_num(a, b):
return a ** b
assert exponentiation_num(5, 2) == 25
# 007
# square root
def count_square_root(a):
return a ** 0.5
assert count_square_root(4) == 2
# 008
# BMI calculator
def bmi(mass, height):
return mass / height ** 2
assert bmi(89, 1.8) == 27.469135802469133
# 009
# check word is palindrome
def check_palindrome(word):
return word == word[::-1]
assert check_palindrome("hello") == False
# 010
# count square area
def square_area(a):
return a * a
assert square_area(4) == 16
# 011
# count rectangle area
def rectangle_area(a, b):
return a * b
assert rectangle_area(2, 3) == 6
# 012
# count triangle area
def triangle_area(a, b, h):
return 0.5 * (a + b) * h
assert triangle_area(2, 3, 4) == 10
# 013
# count perimeter of a square
def square_perimeter(a):
return a * 4
assert square_perimeter(4) == 16
# 014
# count perimeter of a rectangle
def perimeter_rectangle(a, b):
return 2 * (a + b)
assert perimeter_rectangle(4, 4) == 16
# 015
# count perimeter of a triangle
def perimeter_triangle(a, b, c):
return a + b + c
# 016
# count circumference of a circle
def circumference_circle(r):
return 2 * pi * r
assert circumference_circle(4) == 25.132741228718345
# 017
# count circle area
def circle_area(r):
return pi * r * r
assert circle_area(2) == 12.566370614359172
# 018
# count trapezoid area
def trapezoid_area(a, b, h):
return 0.5 * (a + b) * h
assert trapezoid_area(4, 4, 4) == 16
# 019
# count trapezoid perimeter
def trapezoid_perimeter(a, b, c, d):
return a + b + c + d
assert trapezoid_perimeter(4, 4, 4, 4) == 16
# 020
# count cube volume
def cube_volume(a):
return a ** 3
assert cube_volume(4) == 64
# 021
# count cube total surface area
def cube_total_surface_area(a):
return 6 * a * a
assert cube_total_surface_area(2) == 24
# 022
# count cuboid volume
def cuboid_volume(a, b, c):
return a * b * c
assert cuboid_volume(4, 4, 4) == 64
# 023
# count cuboid total surface area
def cuboid_total_surface_area(a, b, c):
return 2 * (a * b + a * c + b * c)
assert cuboid_total_surface_area(4, 4, 4) == 96
# 024
# count sphere area
def sphere_area(r):
return 4 / 3 * pi * r ** 3
assert sphere_area(4) == 268.082573106329
# 025
# count sphere volume
def sphere_volume(r):
return 4 * pi * r ** 2
assert sphere_volume(4) == 201.06192982974676
# 026
# count cone volume
def cone_volume(r, h):
return 1 / 3 * pi * r ** 2 * h
assert cone_volume(4, 4) == 67.02064327658225
# 027
# count cone total area
def cone_total_surface_area(r, l):
return pi * r * (r + l)
assert cone_total_surface_area(4, 4) == 100.53096491487338
# 028
# count cylinder total area
def cylinder_area(r, h):
return 2 * pi * r * (r + h) == 201.06192982974676
# 029
# count cylinder volume
def cylinder_volume(r, h):
return pi * r ** 2 * h
assert cylinder_volume(4, 5) == cylinder_volume(4, 5)
# 030
# count pyramid volume square based
def pyramid_volume_square_based(a, h):
return 1 / 3 * a ** a * h
assert pyramid_volume_square_based(4, 4) == 341.3333333333333
# 030 , 031 , 032
# using list comprehension return new list with only even numbers
list_1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
def create_new_list_even_num(array):
return [num for num in array if not num % 2]
# return [ num for num in array if not num & 1]
assert create_new_list_even_num(list_1) == [2, 4, 6, 8, 10]
# 033 , 034 , 035
# using list comprehension flat list of lists
list_2 = [[1, 3], [2, 4], [3, 5]]
def create_new_flat_list(array):
return [x for y in array for x in y]
assert create_new_flat_list(list_2) == [1, 3, 2, 4, 3, 5]
# 036 , 037 , 038
# using list comprehension multiply each element list by n
def create_new_list_mul_by_n(n, array):
return [item * n for item in array]
assert create_new_list_mul_by_n(10, list_1) == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
# 039 , 040 , 041
# using list comprehension filter list and keep only str value
list_3 = [1, 'home', 3, 'John', 5, 'funeral', 'infinity', 'compulsive', 9, 10]
def create_new_str_list(array):
return [item for item in array if isinstance(item, str)]
assert create_new_str_list(list_3) == ['home', 'John', 'funeral', 'infinity', 'compulsive']
# 042 , 043 , 044
# using dict comprehension create dict from the list
list_4 = ['home', 'John', 'funeral', 'infinity', 'compulsive']
def create_dict_from_list(array):
return {key: value for key, value in enumerate(array)}
assert create_dict_from_list(list_4) == {0: 'home', 1: 'John', 2: 'funeral', 3: 'infinity', 4: 'compulsive'}
# 045 , 046 , 047
# using list comprehension create list from dictionary
dict_1 = {0: 'home', 1: 'John', 2: 'funeral', 3: 'infinity', 4: 'compulsive'}
def create_list_from_dict(any_dict):
return [item for item in any_dict.values()]
assert create_list_from_dict(dict_1) == ['home', 'John', 'funeral', 'infinity', 'compulsive']
# 048 , 049 , 050
# using list comprehension create list of tuples from dictionary
def create_list_tuples_from_dict(any_dict):
return [(key, value) for key, value in any_dict.items()]
assert create_list_tuples_from_dict(dict_1) == [(0, 'home'), (1, 'John'), (2, 'funeral'), (3, 'infinity'),
(4, 'compulsive')]
# 051 , 052 , 053
# using list comprehension create flat list from list of tuples
list_5 = [(0, 'home'), (1, 'John'), (2, 'funeral'), (3, 'infinity'), (4, 'compulsive')]
def create_flat_list_from_list_of_tuples(array):
return [x for y in array for x in y]
assert create_flat_list_from_list_of_tuples(list_5) == [0, 'home', 1, 'John', 2, 'funeral', 3, 'infinity', 4,
'compulsive']
# 054 , 055 , 056
# using list comprehension create list from dictionary using keys
def create_list_from_dict_key(any_dict):
return [key for key in any_dict]
# return [key for key, value in any_dict.items()]
assert create_list_from_dict_key(dict_1) == [0, 1, 2, 3, 4]
# 057 , 058 , 059
# using list comprehension create list from dictionary using values with len condition of value
def create_list_from_dict_value_condition(any_dict):
return [item for item in any_dict.values() if len(item) > 5]
assert create_list_from_dict_value_condition(dict_1) == ['funeral', 'infinity', 'compulsive']
# 060 , 061 , 062
# using list comprehension create list from dictionary using keys and values like a string
def create_list_from_dict_k_v_str(any_dict):
return [f'{key}: {value}' for key, value in any_dict.items()]
assert create_list_from_dict_k_v_str(dict_1) == ['0: home', '1: John', '2: funeral', '3: infinity', '4: compulsive']
# 063 , 064 , 065
# using list comprehension create sliced list
def create_sliced_list(array):
return [item[:3] for item in array]
assert create_sliced_list(list_4) == ['hom', 'Joh', 'fun', 'inf', 'com']
# 066 , 067 , 068
# using list comprehension create new list with item[1]
def create_list_item_one_index(array):
return [item[1] for item in array]
assert create_list_item_one_index(list_4) == ['o', 'o', 'u', 'n', 'o']
# 069 , 070 , 071
# using list comprehension create new list if letter in item
letter = 'n'
def create_list_letter_in_item(array, n):
return [item for item in array if n in item]
assert create_list_letter_in_item(list_4, letter) == ['John', 'funeral', 'infinity']
# 072 , 073 , 074
# using list comprehension create new list if not item % n
def create_list_from_range_modulo_n(n):
return [item for item in range(101) if not item % n]
assert create_list_from_range_modulo_n(18) == [0, 18, 36, 54, 72, 90]
# 075 , 076 , 077
# using list comprehension create new list if not item % n and in the specific scope
def create_list_from_range_modulo_n_and_cond(n, a, b):
return [item for item in range(101) if not item % n and a < item <= b]
assert create_list_from_range_modulo_n_and_cond(20, 40, 80) == [60, 80]
# 078 , 079 , 080
# using list comprehension create new list with dictionary's values capitalized
dict_2 = {0: 'home_AS_a_Hall', 1: ' John2 ', 2: 'funeral123 ', 3: '88infinity',
4: 'compulsive is a bad character treat'}
def create_list_from_dict_36(any_dict):
return [item.capitalize() for item in any_dict.values()]
assert create_list_from_dict_36(dict_2) == ['Home_as_a_hall',
' john2 ',
'Funeral123 ',
'88infinity',
'Compulsive is a bad character treat']
# 081
# string capitalize method
sentence_1 = ' Better now than NEVER '
def str_capitalize(any_str):
return any_str.capitalize()
assert str_capitalize(sentence_1) == ' better now than never '
# 082 , 083 , 084
# using list comprehension create new list with dictionary's values lowered
def create_list_from_dict_lowered(any_dict):
return [item.lower() for item in any_dict.values()]
assert create_list_from_dict_lowered(dict_2) == ['home_as_a_hall',
' john2 ',
'funeral123 ',
'88infinity',
'compulsive is a bad character treat']
# 085
# string lower method
def str_lower(any_str):
return any_str.lower()
assert str_lower(sentence_1) == ' better now than never '
# 086 , 087 , 088
# using list comprehension create new list with dictionary's values upper
def create_list_from_dict_upper(any_dict):
return [item.upper() for item in any_dict.values()]
assert create_list_from_dict_upper(dict_2) == ['HOME_AS_A_HALL',
' JOHN2 ',
'FUNERAL123 ',
'88INFINITY',
'COMPULSIVE IS A BAD CHARACTER TREAT']
# 089
# string lower method
def str_upper(any_str):
return any_str.upper()
assert str_upper(sentence_1) == ' BETTER NOW THAN NEVER '
# 090 , 091 , 092
# using list comprehension create new list with dictionary's values titled
def create_list_from_dict_titled(any_dict):
return [item.title() for item in any_dict.values()]
assert create_list_from_dict_titled(dict_2) == create_list_from_dict_titled(dict_2)
# 093
# string lower method
def str_title(any_str):
return any_str.title()
assert str_title(sentence_1) == ' Better Now Than Never '
# 094
# string swapcase method
def str_swapcase(any_str):
return any_str.swapcase()
assert str_swapcase(sentence_1) == ' bETTER NOW THAN never '
# 095
# string strip method
def str_strip(any_str):
return any_str.strip()
assert str_strip(sentence_1) == 'Better now than NEVER'
# 096
# string strip and title methods
def str_strip_and_title(any_str):
return any_str.strip().title()
assert str_strip_and_title(sentence_1) == 'Better Now Than Never'
# 097
# string replace method
def str_replace(any_str):
return any_str.replace(' ', '_$_$_')
assert str_replace(sentence_1) == '_$_$_Better_$_$_now_$_$_than_$_$_NEVER_$_$__$_$__$_$__$_$__$_$__$_$_'
# 098
# string replace method
def str_replace_and_count(any_str):
return any_str.replace(' ', '_$_$_', 4)
assert str_replace_and_count(sentence_1) == '_$_$_Better_$_$_now_$_$_than_$_$_NEVER '
# 099, 100, 101
# using list comprehension convert list to string
def create_list_to_str():
return ''.join([str(item) for item in range(11)])
assert create_list_to_str() == '012345678910'
# 102, 103, 104
# using list comprehension convert list to string and next to int
def create_list_to_str_to_int():
return int(''.join([str(item) for item in range(11)]))
assert create_list_to_str_to_int() == 12345678910
# 105, 106, 107
# using list comprehension achieve two list from dictionary
def create_lists_from_dict(any_dict):
l_1 = [item for item in any_dict.values()]
l_2 = [item for item in any_dict.keys()]
return l_1, l_2
assert create_lists_from_dict(dict_2) == (
['home_AS_a_Hall', ' John2 ', 'funeral123 ', '88infinity', 'compulsive is a bad character treat'],
[0, 1, 2, 3, 4])
# 108, 109, 110
# using dict comprehension create dict from tuple
my_tuple = ("home", "apple", "tower")
def create_dict_from_tuple(any_tuple):
return {key: value for key, value in enumerate(any_tuple)}
assert create_dict_from_tuple(my_tuple) == {0: 'home', 1: 'apple', 2: 'tower'}
sentence_2 = 'New York 76st'
# 111
# string isalnum method , are there only letters and digits in the str
def str_isalnum(any_str):
return any_str.isalnum()
assert str_isalnum(sentence_2) == False
# 112
# string isalpha method , are there only letters in the str
def str_isalpha(any_str):
return any_str.isalpha()
assert str_isalpha(sentence_2) == False
# 113
# string isalpha method , are there only digits in the str
def str_isdigit(any_str):
return any_str.isdigit()
assert str_isdigit('1234') == True
# 114
# string isdecimal method , are there only decimal digits in the str
def str_isdecimal(any_str):
return any_str.isdecimal()
assert str_isdecimal('1234') == True
# 115
# string isnumeric method , are there only numbers in the str
def str_isnumeric(any_str):
return any_str.isnumeric()
assert str_isnumeric('12 34') == False
# 116
# string islower method , are there only lower letters in the str
def str_islower(any_str):
return any_str.islower()
assert str_islower('where is the bus stop') == True
# 117
# string isupper method , are there only upper letters in the str
def str_isupper(any_str):
return any_str.isupper()
assert str_isupper('where is the bus stop') == False
# 118
# string isspace method , are there only white signs in the str
def str_isspace(any_str):
return any_str.isspace()
assert str_isspace(' ') == True
# 119
# string split method , create list from str using split
def str_split(any_str):
return any_str.split(',')
assert str_split('ab,cd,ef') == ['ab', 'cd', 'ef']
# 120
# using join method , create str from list of str
def list_join(any_list_str):
return ', '.join(any_list_str)
assert list_join(['ab', 'cd', 'ef']) == 'ab, cd, ef'
# 121
# Write a function that given a floor in the american system returns the floor in the european system.
# Examples
#
# 1 => 0
# 0 => 0
# 5 => 4
# 15 => 13
# -3 => -3
def get_real_floor(n):
return n if n < 1 else n - 1 if n < 13 else n - 2
assert get_real_floor(5) == 4
handball_elite = [
{
"name": "FC Barcelona",
"country": "Spain",
"city": "Barcelona",
"founded": 1942,
"arena": "Palau Blaugrana",
"capacity": 7500,
"colors": ["burgundy", "navy blue"],
"successes_in_cl": {"1st": 12, "2nd": 5, "3rd": 3},
},
{
"name": "SC Magdeburg",
"country": "Germany",
"city": "Magdeburg",
"founded": 1955,
"arena": "GETEC Arena",
"capacity": 8000,
"colors": ["green", "red"],
"successes_in_cl": {"1st": 4, "2nd": 0, "3rd": 0},
},
{
"name": "THW Kiel",
"country": "Germany",
"city": "Kiel",
"founded": 1904,
"arena": "Sparkassen",
"capacity": 10250,
"colors": ["white", "black"],
"successes_in_cl": {"1st": 4, "2nd": 4, "3rd": 3},
},
{
"name": "AaB Handbold",
"country": "Denmark",
"city": "Aalborg",
"founded": 2000,
"arena": "Jutlander",
"capacity": 5020,
"colors": ["red", "white"],
"successes_in_cl": {"1st": 0, "2nd": 2, "3rd": 0},
},
{
"name": "Paris SG Handball",
"country": "France",
"city": "Paris",
"founded": 1941,
"arena": "Stade Pierre",
"capacity": 4500,
"colors": ["blue", "red", "white"],
"successes_in_cl": {"1st": 0, "2nd": 1, "3rd": 4},
},
{
"name": "KS Iskra Kielce",
"country": "Poland",
"city": "Kielce",
"founded": 1965,
"arena": "Hala Legionów",
"capacity": 4200,
"colors": ["yellow", "blue", "white"],
"successes_in_cl": {"1st": 1, "2nd": 2, "3rd": 2},
},
{
"name": "MKB Veszprem KC",
"country": "Hungary",
"city": "Veszprem",
"founded": 1977,
"arena": "Veszprém",
"capacity": 5096,
"colors": ["red", "white"],
"successes_in_cl": {"1st": 0, "2nd": 4, "3rd": 1},
},
{
"name": "Fuechse Berlin",
"country": "Germany",
"city": "Berlin",
"founded": 1891,
"arena": "Max Schmeling",
"capacity": 8500,
"colors": ["green", "black", "white"],
"successes_in_cl": {"1st": 0, "2nd": 0, "3rd": 0},
},
{
"name": "SG Flensburg-Handewitt",
"country": "Germany",
"city": "Flensburg-Handewitt",
"founded": 1990,
"arena": "Flens Arena",
"capacity": 6300,
"colors": ["blue", "red", "white"],
"successes_in_cl": {"1st": 1, "2nd": 2, "3rd": 0},
},
{
"name": "Sporting Clube de Portugal",
"country": "Portugal",
"city": "Lisbon",
"founded": 1932,
"arena": "Pavilhão",
"capacity": 3000,
"colors": ["green", "white"],
"successes_in_cl": {"1st": 0, "2nd": 0, "3rd": 0},
},
{
"name": "Montpellier HB",
"country": "France",
"city": "Montpellier",
"founded": 1982,
"arena": "FDI Stadium",
"capacity": 9000,
"colors": ["blue", "white"],
"successes_in_cl": {"1st": 2, "2nd": 0, "3rd": 0},
},
{
"name": "Wisla Plock",
"country": "Poland",
"city": "Płock",
"founded": 1964,
"arena": "Orlen Arena",
"capacity": 5492,
"colors": ["blue", "white"],
"successes_in_cl": {"1st": 0, "2nd": 0, "3rd": 0},
},
{
"name": "SC Pick Szeged",
"country": "Hungary",
"city": "Szeged",
"founded": 1961,
"arena": "Pick Aréna",
"capacity": 8143,
"colors": ["blue", "white"],
"successes_in_cl": {"1st": 0, "2nd": 0, "3rd": 0},
},
{
"name": "HBC Nantes",
"country": "France",
"city": "Nantes",
"founded": 1953,
"arena": "Palais des",
"capacity": 10750,
"colors": ["pink", "yellow"],
"successes_in_cl": {"1st": 0, "2nd": 1, "3rd": 0},
},
{
"name": "GOG Svendborg TGI",
"country": "Denmark",
"city": "Gudme",
"founded": 1973,
"arena": "Phønix Tag",
"capacity": 2265,
"colors": ["yellow", "red"],
"successes_in_cl": {"1st": 0, "2nd": 0, "3rd": 0},
},
{
"name": "Dinamo Bucarest",
"country": "Romania",
"city": "Bucarest",
"founded": 1953,
"arena": "Sala Polivalentă",
"capacity": 5300,
"colors": ["red", "white"],
"successes_in_cl": {"1st": 1, "2nd": 1, "3rd": 0},
},
{
"name": "RK Nexe Nasice",
"country": "Croatia",
"city": "Nasice",
"founded": 1959,
"arena": "Sportska",
"capacity": 2500,
"colors": ["green", "black"],
"successes_in_cl": {"1st": 0, "2nd": 0, "3rd": 0},
},
{
"name": "RK Croatia Zagreb",
"country": "Croatia",
"city": "Zagreb",
"founded": 1922,
"arena": "Arena Zagreb",
"capacity": 15200,
"colors": ["blue", "white", "red"],
"successes_in_cl": {"1st": 2, "2nd": 4, "3rd": 0},
},
{
"name": "Rhein Neckar Löwen",
"country": "Germany",
"city": "Lowen",
"founded": 2002,
"arena": "SAP Arena",
"capacity": 14500,
"colors": ["yellow", "navy blue"],
"successes_in_cl": {"1st": 0, "2nd": 0, "3rd": 1},
},
{
"name": "Valur",
"country": "Iceland",
"city": "Reykjavík",
"founded": 1911,
"arena": "N höllin",
"capacity": 1300,
"colors": ["red", "white"],
"successes_in_cl": {"1st": 0, "2nd": 0, "3rd": 0},
}
]
# 122, 123, 124
# Write a function that return list of tuples and takes list of dictionaries
# question : What are the 3 oldest clubs (among those mentioned) and how many years ago were they founded ?
def three_oldest_club(data):
sorted_clubs = sorted(data, key=lambda x: x['founded'])