Filters
Question type

Study Flashcards

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

Correct Answer

verifed

verified

A list cannot be passed as an argument to a function.

A) True
B) False

Correct Answer

verifed

verified

What are the data items in the list called?


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

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

Correct Answer

verifed

verified

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) A) and C)
F) A) and D)

Correct Answer

verifed

verified

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


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

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

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) B) and C)
F) A) and D)

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

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

Correct Answer

verifed

verified

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

A) True
B) False

Correct Answer

verifed

verified

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


A) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
B) [1, 3, 5, 7, 9]
C) [2, 4, 6, 8]
D) [0, 2, 4, 6, 8]

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

Correct Answer

verifed

verified

The index - 1 identifies the last element in a list.

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 is the advantage of using tuples over lists?


A) Tuples are not limited in size.
B) Tuples can include any data type as an element.
C) Processing a tuple is faster than processing a list.
D) There is no advantage.

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

Correct Answer

verifed

verified

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


A) when creating a tuple you don't use commas to separate elements
B) a tuple can only include string elements
C) a tuple cannot include lists as elements
D) once a tuple is created, it cannot be changed

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

Correct Answer

verifed

verified

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

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 D)
F) All of the above

Correct Answer

verifed

verified

A

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


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

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

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 = list1 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) All of the above

Correct Answer

verifed

verified

B

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

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

A) True
B) False

Correct Answer

verifed

verified

False

Showing 1 - 20 of 35

Related Exams

Show Answer