Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need help answering a few questions about object-oriented programming with Pytho

ID: 3704815 • Letter: N

Question

Need help answering a few questions about object-oriented programming with Python 3!

1. What happens if we create an attribute whose name starts with "__"?

A. Error

B. Nothing special

C. Python automatically appends _<Classname>, where <Classname> is the name of the class, in front of the attribute name when accessed from outside the class

D. It makes it impossible to access this attribute from outside the class

2. Creating a public interface is important because

A. It provides a set of methods for a user to use in order to ensure that attributes are set and gotten correctly.

B. It keeps attribute data private within the class

C. It allows for abstraction

D. It provides a set of alternative constructors for creating an instance of a class

3. All classes must define an __init__ method

A. True

B. False

4. Attributes of a class can only be basic data types (integer, floating point numbers, etc..)

A. True

B. False

5. The myMethod method of a class is defined below:

def myMethod(self, y)
x = y

What is happening in the line x=y?

A. A syntax error occurs

B. The attribute x is assigned the value stored in y

C. An attribute of the object is created (and called x) and assigned the value stored in y

D. A local variable x is created and assigned the value stored in y

Explanation / Answer

1) It makes it impossible to access this attribute from outside the class 2) It allows for abstraction 3) B. False 4) B. False 5) D. A local variable x is created and assigned the value stored in y

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote