``` # --------------------- ​ ​ 1) Get users who attended some activity more than twice. ​ """ SELECT * FROM users; ​ user_id username 1 John Doe 2 Jane Don 3 Alice Jones 4 Lisa Romero ​ SELECT * FROM training_details; ​ user_training_id user_id training_id training_date 1 1 1 "2015-08-02" 2 2 1 "2015-08-03" 3 3 2 "2015-08-02" 4 4 2 "2015-08-04" 5 2 2 "2015-08-03" 6 1 1 "2015-08-02" 7 3 2 "2015-08-04" 8 4 3 "2015-08-03" 9 1 4 "2015-08-03" 10 3 1 "2015-08-02" 11 4 2 "2015-08-04" 12 3 2 "2015-08-02" 13 1 1 "2015-08-02" 14 4 3 "2015-08-03" """ -------------------- ​ """ ​ 2) Implement a group_by_owners that: Accepts a dictionary containing the file owner name for each file name. Returns a dictionary containing a list of file names for each owner name, in any order. For example, dictionary: { 'Input.txt': 'Randy', 'Code.py': 'Stan', 'Output.txt': 'Randy' } ​ the group_by_owners function should return: { 'Randy': ['Input.txt', 'Output.txt'], 'Stan': ['Code.py'] } """ #---------------------- """ 3) Sort list of objects by age field in ascending order """ ​ """ Input: """ ​ animals = [ {'type': 'penguin', 'name': 'Stephanie', 'age': 8}, {'type': 'elephant', 'name': 'Devon', 'age': 3}, {'type': 'puma', 'name': 'Moe', 'age': 5}, ] ​ """ Output: """ ​ sorted_animals = [ {'type': 'elephant', 'name': 'Devon', 'age': 3}, {'type': 'puma', 'name': 'Moe', 'age': 5}, {'type': 'penguin', 'name': 'Stephanie', 'age': 8} ] ---------------------- 4) What will be the output of the following code snippet? """ class Person: def __init__(self, id): self.id = id ​ sam = Person(100) sam.__dict__['age'] = 49 print(sam.age + len(sam.__dict__)) --------------------- ​ """ ​ 5) What will be the output of the following code snippet? """ ​ class View: def __init__(self): self.calcI(30) print("i from A is", self.i) def authorise(self, i): pass class AuhtorisedView(View): def __init__(self): super().__init__() def authorise(self, i): if not_authorised(self, request): raise NotAuthorised ​ b = B() --------------- 6) Write a code snippet that returns all pairs of numbers that return sum of 10 [0, -1, 9, 9, 1, 3, 6, 7, 1] ``` def get_pairs(numbers): result = [] if len(numbers < 2): return result for i, first in enumerate(numbers): for second[i:] in numbers: if first + second == 10: result.append((first, second)) @pytest.mark.parametrize( "numbers, expected", [ ([1, 9, 5, 5, 2, 4], [(1, 9), (5, 5)]) ([], []) ([5], []), ([1,2,5], []), ] ) def test_get_pairs():