Which of the following will set the button text's font to 12 point italics Anal? (Select two answers)
Correct Answer: B,C
Explanation Option B is correct because it sets the font option of the button to a tuple containing the font family ('Arial'), size (12), and style ('italic'). Option C is correct because it sets the font option of the button to a string containing the font family ('Arial'), size (12), and style ('italic') separated by spaces.
Question 2
Select the true statement about composition
Correct Answer: B
Explanation Composition is an object-oriented design concept that models a has-a relationship. In composition, a class known as composite contains an object of another class known as component. In other words, a composite class has a component of another class1. Composition allows a class to be projected as a container of different classes. Composition is a concept in Python that allows for building complex objects out of simpler objects, by aggregating one or more objects of another class as attributes. The objects that are aggregated are generally considered to be parts of the whole object, and the containing object is often viewed as a container for the smaller objects. In composition, objects are combined in a way that allows for greater flexibility and modifiability than what inheritance can offer. With composition, it is possible to create new objects by combining existing objects, by using a container object to host other objects. By contrast, with inheritance, new objects extend the behavior of their parent classes, and are limited by that inheritance hierarchy. References: * Official Python documentation on Composition: https://docs.python.org/3/tutorial/classes.html#composition * GeeksforGeeks article on Composition vs Inheritance: https://www.geeksforgeeks.org/composition-vs-inheritance-python/ * Real Python article on Composition and Inheritance: https://realpython.com/inheritance-composition-python/
Question 3
Which of the following examples using line breaks and different indentation methods are compliant with PEP 8 recommendations? (Select two answers.)
Correct Answer: B,D
Explanation The correct answers are B. Option B and D. Option D. Both options B and D are compliant with PEP 8 recommendations for line breaks and indentation. PEP 8 recommends using 4 spaces per indentation level and breaking lines before binary operators. In option B, the arguments to the print function are aligned with the opening delimiter, which is another acceptable way toformat long lines according to PEP 8. In option D, the second line is indented by 4 spaces to distinguish it from the next logical line.
Question 4
Which of the following methods allow you to load a configuration using ConfigParser? (Select two answers.)
Correct Answer: A,D
Explanation ConfigParser is a built-in library in Python that allows you to read and write configuration files. The read method is used to read the configuration file which can be in any of the supported file formats, such as INI, YAML, and JSON. The read_dict method is used to read the configuration from a Python dictionary. The read_conf and read_str options are not valid methods in the ConfigParser module. Therefore, the correct options to load a configuration using ConfigParser are A. read and D. read_string.
Question 5
Analyze the code and choose the best statement that describes it.
Correct Answer: D
Explanation The correct answer is D. The code is responsible for the support of the inequality operator i.e. i != j. In the given code snippet, the __ne__ method is a special method that overrides the behavior of the inequality operator != for instances of the MyClass class. When the inequality operator is used to compare two instances of MyClass, the __ne__ method is called to determine whether the two instances are unequal.