Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PYTHON: 1. What is the name of the method in the following code segment? class Fruit : def getColor(self) : return self._color answer choices: _color

PYTHON:

1. What is the name of the method in the following code segment?

class Fruit :

def getColor(self) : return self._color

answer choices:

_color

fruit

getColor

self

2. Which of the following is NOT a difference between methods and functions?

A method is defined as part of a class definition

A function is defined as part of a class definition

The first parameter variable of a method is called self

A method can access the instance variables of an object

3. Python's ____ statement allows an exception to be caught and the program to recover.

try-catch

try-except

assert

except

4. Naming conventions for Python dictate that instance variables should start with an underscore to represent ____.

public visibility

private visibility

encapsulation

public interface

5. Python includes a module that allows the programmer to save and load objects using a process called ____.

serial-construct

streamize

pickling

converting

6. "Which of the following method headers represent a constructor for an Employee class, assuming we add a colon to each?"

def Employee(self)

def_init()_

def_Employee_(self)

def_init_(self)

7. What is the purpose of an object's instance variables?

Store data temporarily until a method completes

Store the data for each individual instance created by a class

To provide access to the data of an object

To create variables with public visibility

8. You should use _____ to read an object from the file.

objectName = pickle.load(file_variable)

"pickle.dump(objectName, file_Variable)"

9. Given the following class definition, what is printed after executing this code snippet?

class PhoneNumber :

def __init__(self, lName, phone = '215-555-1212') : self._name = lName self._phone = phone

Jones = PhoneNumber("Jones") print(Jones._name, Jones._phone)

answer choices:

Jones 215-555-1212

IOError

'phoneNumber' object has no attribute

Jones

Jones 000-000-0000

10. "Most classes include a special method named ____, which is the class's constructor."

_self

_self_

_init

_init_

11. Methods that allow a user to modify an objects states are called _________.

mutators

modifiers

writers

output methods

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions