What is true about the invocation of the cget () method?
Correct Answer: A
Explanation The cget() method in Python is used to read the configuration options of a widget in Tkinter. It retrieves the value of a specified configuration option for a Tkinter widget. Hence, option A is the correct answer.
PCPP-32-101 Exam 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/
PCPP-32-101 Exam Question 3
Select the true statements related to PEP 8 naming conventions. (Select two answers.)
Correct Answer: A,D
Explanation Option A is true because PEP 8 recommends that function and variable names should be lowercase, with words separated by underscores . Option D is true because PEP 8 recommends that constants should be written in all capital letters with words separated by underscores . PEP 8 is the official style guide for Python code. It provides guidelines for how to write readable code that follows consistent naming conventions. The aim of PEP 8 is to improve the readability of Python code and make it easier to understand and maintain. According to PEP 8, variable and function names should be written in all lower-case letters with words separated by underscores, as stated in A. Constants, which are variables whose value is expected to remain constant throughout the code, should be written in all upper-case letters with words separated by underscores, as stated in D. References: * PEP 8 -- Style Guide for Python Code: https://www.python.org/dev/peps/pep-0008/ * Python Documentation: https://docs.python.org/3/tutorial/classes.html#classmethods-and-staticmethods
PCPP-32-101 Exam Question 4
Select the true statements related to PEP 8 programming recommendations for code writing. (Select two answers:)
Correct Answer: B,D
Explanation The two true statements related to PEP 8 programming recommendations for code writing are Option B and Option D. Option B is true because PEP 8 recommends making object type comparisons using the isinstance() method instead of comparing types directly 1. Option D is true because PEP 8 recommends not writing string literals that rely on significant trailing whitespaces as they may be visually indistinguishable, and certain editors may trim them 1.
PCPP-32-101 Exam Question 5
Which of the following values can be returnedby the messagebox. askquestion () method?
Correct Answer: C
Explanation The messagebox.askquestion() method in Python's tkinter library displays a message box with a specified question and two response buttons labeled "Yes" and "No". It returns a string indicating which button was selected - either "yes" or "no". This function is used to ask questions to the user that have only two options: YES or NO. It can be used to ask the user if they want to continue or if they want to submit something 1.