Filters
Question type

Study Flashcards

Invalid indexes do not cause slicing expressions to raise an exception.

A) True
B) False

Correct Answer

verifed

verified

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


A) [1, 2] * 3
B) [3, 6]
C) [1, 2, 1, 2, 1, 2]
D) [[1, 2], [1, 2], [1, 2]]

E) B) and D)
F) B) and C)

Correct Answer

verifed

verified

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

A) True
B) False

Correct Answer

verifed

verified

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


A) append
B) tuple
C) insert
D) list

E) None of the above
F) C) and D)

Correct Answer

verifed

verified

What are the data items in the list called?


A) data
B) elements
C) items
D) values

E) C) and D)
F) B) and D)

Correct Answer

verifed

verified

B

What is the first negative index in a list?


A) 0
B) -1
C) -0
D) Size of the string or list minus one

E) None of the above
F) All of the above

Correct Answer

verifed

verified

The _______________ exception is raised when a search item is not in the list being searched.

Correct Answer

verifed

verified

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]


A) [1, 2, 3]
B) [4, 5, 6]
C) [1, 2, 3, 4, 5, 6]
D) invalid code

E) B) and C)
F) A) and C)

Correct Answer

verifed

verified

The _______________ method reverses the order of the items in the list.

Correct Answer

verifed

verified

reverse

When working with multiple sets of data, one would typically use a(n) _____.


A) list
B) tuple
C) nested list
D) Sequence

E) None of the above
F) All of the above

Correct Answer

verifed

verified

A(n) _______________ is a span of items that are taken from a sequence.

Correct Answer

verifed

verified

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

A) True
B) False

Correct Answer

verifed

verified

Lists are _______________, which means their elements can be changed.

Correct Answer

verifed

verified

Tuples are _______________ sequences, which means that once a tuple is created, it cannot be changed.

Correct Answer

verifed

verified

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

A) True
B) False

Correct Answer

verifed

verified

Each element in a tuple has a(n) _______________ that specifies its position in the tuple.

Correct Answer

verifed

verified

What method or operator can be used to concatenate lists?


A) *
B) +
C) %
D) concat

E) C) and D)
F) All of the above

Correct Answer

verifed

verified

The _______________ function returns the item that has the lowest value in the sequence.

Correct Answer

verifed

verified

The remove method removes all occurrences of the item from a list.

A) True
B) False

Correct Answer

verifed

verified

The _______________ method is commonly used to add items to a list.

Correct Answer

verifed

verified

append

Showing 1 - 20 of 35

Related Exams

Show Answer