ProgFund1 Exam 3

¡Supera tus tareas y exámenes ahora con Quizwiz!

True/False: A class might be thought of as a 'blueprint' that an object may be created from.

True

True/False: If a whole paragraph is included in a single string, the split() method can be used to obtain a list of the sentences included in the paragraph.

True

True/False: If the + operator is used on strings, it produces a string that is the combination of the two strings used as its operands.

True

True/False: In slicing, if the end index specifies a position beyond the end of the list, Python will use the length of the list instead.

True

True/False: In slicing, if the end index specifies a position beyond the end of the string, Python will use the length of the string instead.

True

True/False: Indexing works with both strings and lists.

True

True/False: Invalid indexes do not cause slicing expressions to raise an exception.

True

True/False: Lists are dynamic data structures such that items may be added to them or removed from them.

True

True/False: Object-oriented programming allows us to hide the object's data attributes from code that is outside the object.

True

True/False: Procedures operate on data items that are separate from the procedures.

True

True/False: The first step in calculating the average of the values in a list is to get the total of the values.

True

True/False: The index - 1 identifies the last character in a string.

True

True/False: The index - 1 identifies the last element in a list.

True

True/False: The self parameter is required in every method of a class.

True

True/False: The self parameter need not be named self, but it is strongly recommended to conform with standard practice.

True

What does the acronym UML stand for?

Unified Modeling Language

Which list will be referenced by the variable list_strip after the execution of the following code? list_string='03/07/2008' list_strip=list_string.split('/')

['03', '07', '2008']

Which list will be referenced by the variable number after the execution of the following code? number = list ( range (0, 9, 2) )

[0, 2, 4, 6, 8]

What would be the value of the variable list after the execution of the following code? list=[1,2] list=list*3

[1, 2, 1, 2, 1, 2]

What would be the value of the variable list after the execution of the following code? list=[1,2,3,4] list[3]=10

[1, 2, 3, 10]

What would be the value of the variable list2 after the execution of the following code? list1 = [1, 2, 3] list2 = [] for element in list1: list2.append(element) list1 = [4, 5, 6]

[1, 2, 3]

What would be the value of the variable list2 after the execution of the following code? list1=[1,2,3] list2=list1 list1=[4,5,6]

[4,5,6]

Which method is automatically executed when an instance of the class is created in memory?

__init__

What is the special name given to the method that returns a string containing the object's state?

__str__

What type of method provides a safe way for code outside a class to retrieve the values of attributes, without exposing the attributes in a way that they could be changed by the code outside the method?

accessor

In a dictionary, what would you use if an element is to be removed from a specific index?

del statement

What are the data items in the list called?

elements

What is the combining of data and code in a single object known as?

encapsulation

Which method would you use to determine whether a substring is the suffix of a string?

endswith(substring)

Which method would you use to determine whether a substring is present in a string?

find(substring)

What is another name for the accessor methods?

getters

If the start index is ________ the end index, the slicing expression will return an empty string.

greater than

What method can be used to place an item in the list at a specific index?

insert

What attributes belong to a specific instance of the class?

instance

Which of the following string methods can be used to determine if a string contains only '\n' characters?

isspace()

What method can be used to convert a tuple to a list?

list

What are the procedures that an object performs called?

methods

When working with multiple sets of data, one would typically use a ________.

nested list

What is, conceptually, a self-contained unit that consists of data attributes and methods that operate on the data attributes?

object

What type of programming contains class definitions?

object-oriented

The primary difference between a tuple and list is that ________.

once a tuple is created, it cannot be changed

A(n) ________ is a set of real-world objects, parties, and major events related to the problem.

problem domain

Which section in the UML holds the list of the class's data attributes?

second

When a method is called, what does Python make to reference the specific object on which the method is supposed to operate?

self parameter

What is another name for the mutator methods?

setters

What is the return value of the string method lstrip()?

the string with all leading whitespaces removed

Which section in the UML holds the list of the class's methods?

third

What method can be used to convert a list to a tuple?

tuple

What will be assigned to the string variable even after the execution of the following code? special='0123456789' even=special[0:10:2]

'02468'

What will be assigned to s_string after the execution of the following code? special='1357 Country Ln.' s_string=special[ :4]

'1357'

What will be assigned to s_string after the execution of the following code? special='1357 Country Ln.' s_string=special[4: ]

'Country Ln.'

What is the value of the variable string after the execution of the following code? string='Hello' string+='world'

'Hello world'

What will be assigned to s_string after the execution of the following code? special='1357 Country Ln.' s_string=special[-3: ]

'Ln.'

What is the value of the variable string after the execution of the following code? string='abcd' string.upper()

'abcd'

What will be assigned to the string variable pattern after the execution of the following code? i=3 pattern='z'*(5*i)

'zzzzzzzzzzzzzzz'

What method or operator can be used to concatenate lists?

+

What is the first negative index in a list?

-1

What is the first negative index in a string?

-1

What are the valid indexes for the string 'New York'?

0 through 7

True/False: A class definition is stored in the library so that it can be imported into any program.

False

True/False: A list cannot be passed as an argument to a function.

False

True/False: A mutator method has no control over the way that a class's data attributes are modified.

False

True/False: An expression of the form string[i] = 'i' is a valid expression.

False

True/False: An object is a stand-alone program but is used by programs that need its service.

False

True/False: Arrays, which most other programming languages allow, have much more capabilities than list structures.

False

True/False: In a UML diagram, the middle section holds the list of the class's methods.

False

True/False: Indexing of a string starts at 1, so the index of the first character is 1, the index of the second character is 2, and so forth.

False

True/False: Indexing starts at 1, so the index of the first element is 1, the index of the second element is 2, and so forth.

False

True/False: The instances of a class share the data attributes in the class.

False

True/False: The remove method removes all occurrences of the item from a list.

False

True/False: The sort method rearranges the elements of a list so they appear in ascending or descending order.

False

True/False: The strip() method returns a copy of the string with all leading whitespace characters removed, but does not remove trailing whitespace characters.

False

True/False: When accessing each character in a string, such as for copying purposes, you would typically use a while loop.

False

What is the advantage of using tuples over lists?

Processing a tuple is faster than processing a list.


Conjuntos de estudio relacionados

Meaning and Dimensions of Culture

View Set

chapter 17 (late 60s psychedelic rock)

View Set

Law & Ethics for Medical Careers

View Set

Midterm Review for Advanced Java

View Set

Recognizing Patterns: Assignment

View Set

Ch5-The Physical Geography of the US and Canada|World Geography

View Set

Characteristics of the Earth that are Necessary to Support Life

View Set