Bienvenido al test sobre Python Para comenzar pulsa sobre el botón de Iniciar.Dispones de 15 minutos para responder el mayor número posible de respuestas correctas.Las preguntas tendrán una única respuesta correcta.Si has terminado el test antes del tiempo establecido, pulsa el botón Finalizar para enviarlo. Para comenzar el test, completa tus datos y pulsa el botón "Siguiente" Nombre completo Email 1 median average mean mode 2 class Game.LogicGame(): pass class Game(LogicGame): pass def Game.LogicGame(): pass def Game(LogicGame): pass 3 A set is an ordered collection of non-unique items. A list is an unordered collection of unique items. A set is an ordered collection unique items. A list is an unordered collection of non-unique items. Elements can be retrieved from a list but they cannot be retrieved from a set. A set is an unordered collection unique items. A list is an ordered collection of non-unique items 4 The __init__ method is a constructor method that is called automatically whenever a new object is created from a class. It sets the initial state of a new object. The__init__ method is included to preserve backwards compatibility from Python 3 to Python 2, but no longer needs to be used in Python 3. The __init__ method makes classes aware of each other if more than one class is defined in a single code file. The __init__ method initializes any imports you may have included at the top of your file. 5 tuple duplication tuple matching tuple assignment tuple unpacking 6 [0,2,0,0] {0,2} {2} [2] 7 There is no real purpose for the self method; it's just historic computer science jargon that Python keeps to stay consistent with other programming languages. self refers to the class that was inherited from to create the object using self. self refers to the instance whose method was called. self means that no other arguments are required to be passed into the method. 8 a tuple subclass with non-iterable parameter fields a generic object class with non-iterable named fields a tuple subclass with iterable named fields a generic object class with iterable parameter fields 9 The any() function returns a Boolean value that answers the question "Are there any items in this list?" The any() function will randomly return any item from the list. The any() function takes as arguments the list to check inside, and the item to check for. If "any" of the items in the list match the item to check for, the function returns True. The any() function returns True if any item in the list evaluates to True. Otherwise, it returns False. 10 It returns a 5-dimensional array of size 1x2x3x4x5 filled with 1s. It returns an array with the values 1,2,3,4,5 It returns a 5x5 matric; each row will have the values 1,2,3,4,5. It returns five different square matrices filled with ones. The first is 1x1, the second 2x2, and so on to 5x5 11 It converts a complex value type into simpler value types. It creates a path from multiple values in an iterable to a single value. It creates a mapping between two different elements of different iterables. It applies a function to each item in an iterable and returns the value of that function. 12 You use a mixin to allow a decorator to accept keyword arguments. You use a mixin to make sure that a class's attributes and methods don't interfere with global variables and functions. If you have many classes that all need to have the same functionality, you'd use a mixin to define that functionality. You use a mixin to force a function to accept an argument at runtime even if the argument wasn't included in the function's definition. 13 defaultdict will automatically create a dictionary for you that has keys which are the integers 0-10. defaultdict forces a dictionary to only accept keys that are of the types specified when you created the defaultdict (such as strings or integers). defaultdict stores a copy of a dictionary in memory that you can default to if the original gets unintentionally modified. If you try to read from a defaultdict with a nonexistent key, a new default key-value pair will be created for you instead of throwing a KeyError. 14 in camel case without using underscores to separate words -- e.g. maxValue = 255 in lowercase with underscores to separate words -- e.g. max_value = 255 in all caps with underscores separating words -- e.g. MAX_VALUE = 255 in mixed case without using underscores to separate words -- e.g. MaxValue = 255 15 The smallest numeric value would go in the top most node. The next highest number would go in its left child node, the the next highest number after that would go in its right child node. This pattern would continue until all numeric values were in their own node. Binary Search Tree cannot be used to organize and search through numeric data, given the complication that arise with very deep trees. For any given Node in a binary Search Tree, the child node to the left is less than the value of the given node and the child node to its right is greater than the given node. The top node of the binary search tree would be an arbitrary number. All the nodes to the left of the top node need to be less than the top node's number, but they don't need to ordered in any particular way. 16 a set of all the multiples of 3 less then 100 a list of all the multiples of 3 less then 100 a set of all the number from 0 to 100 multiplied by 3 a set of all the multiples of 3 less then 100 excluding 0 17 1.5 = fruit_info ['price] my_list['price'] == 1.5 my_list [3.5] = 1.5 fruit_info ['price'] = 1.5 18 python3 python3 doctest python3 rundoctests python3 -m doctest 19 [(2019, 2020, 2021, 2022), ('Freshman', 'Sophomore', 'Junior', 'Senior')] [('Freshman', 'Sophomore', 'Junior', 'Senior'), (2019, 2020, 2021, 2022)] [('Freshman', 2019), ('Sophomore', 2020), ('Junior', 2021), ('Senior', 2022)] [(2019, 'Freshman'), (2020, 'Sophomore'), (2021, 'Junior'), (2022, 'Senior')] 20 The with keyword lets you choose which application to open the file in. When you open a file using the with keyword in Python, Python will make sure the file gets closed, even if an exception or error is thrown. There is no benefit to using the with keyword for opening a file in Python. The with keyword acts like a for loop, and lets you access each line in the file one by one 3 out of 2