CHAPTER 8

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

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

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

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

FALSE

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

Immutable

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]

d. [0, 2, 4, 6, 8]

What method can be used to convert a tuple to a list? a. append b. tuple c. insert d. list

d. list

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

d. once a tuple is created, it cannot be changed

The built-in function _______________ returns the length of a sequence.

len

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

min

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

FALSE

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

Append

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

Mutable

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

Reverse

A(n) _______________ is an object that holds multiple items of data.

Sequence

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

TRUE

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

ValueError

What would be the value of the variable list after the execution of the following code? list = [1, 2, 3, 4] list[3] = 10 a. [1, 2, 3, 10] b. [1, 2, 10, 4] c. [1, 10, 10, 10] d. invalid code

a. [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] a. [1, 2, 3] b. [4, 5, 6] c. [1, 2, 3, 4, 5, 6] d. invalid code

a. [1, 2, 3]

What would you use if an element is to be removed from a specific index? a. del statement b. remove method c. index method d. slice method

a. del statement

What method or operator can be used to concatenate lists? a. * b. + c. % d. concat

b. +

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

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

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

TRUE

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

TRUE

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

TRUE

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

Slice

What is the first negative index in a list? a. 0 b. -1 c. -0 d. Size of the string or list minus one

b. -1

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

Index

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

b. [4, 5, 6]

What are the data items in the list called? a. data b. elements c. items d. values

b. elements

What method can be used to convert a list to a tuple? a. append b. tuple c. insert d. list

b. tuple

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.

c. Processing a tuple is faster than processing a list.

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]]

c. [1, 2, 1, 2, 1, 2]

What method can be used to place an item in the list at a specific index? a. append b. index c. insert d. Add

c. insert

When working with multiple sets of data, one would typically use a(n) _____. a. list b. tuple c. nested list d. Sequence

c. nested list


संबंधित स्टडी सेट्स

Nursing of Adults: Neurological Disorders Part II

View Set

Bio 1 - Chapter 20: Genes Within Populations

View Set

PSYC 3083 Counseling Psychology Final

View Set

Chapter 16 - Nervous System: Senses

View Set

Ch. 11 Homework/Review Questions

View Set

Ch5 Life insurance underwriting and policy issue

View Set

The Crucible - Reverend Samuel Parris Act 2 Scene 3

View Set

NUR 139 Review Questions: CH 41 Antitubercular Drugs

View Set