Introduction to Programming – Chapter 7

Your page rank:

Total word count: 614
Pages: 2

Calculate the Price

- -
275 words
Looking for Expert Opinion?
Let us have a look at your work and suggest how to improve it!
Get a Consultant

b. elements

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

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

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]

a. del statement

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

b. -1

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

c. insert

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. [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] list = list * 3 a. [1, 2] * 3 b. [3, 6] c. [1, 2, 1, 2, 1, 2] d. [[1, 2], [1, 2], [1, 2]]

a. [1, 2, 3, 10]

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

b. +

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

b. [4, 5, 6]

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

a. [1, 2, 3]

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

c. nested list

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

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

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

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

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.

b. tuple

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

d. list

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

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.

False

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

False

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

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.

True

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

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.

True

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

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.

Share This
Flashcard

More flashcards like this

NCLEX 10000 Integumentary Disorders

When assessing a client with partial-thickness burns over 60% of the body, which finding should the nurse report immediately? a) ...

Read more

NCLEX 300-NEURO

A client with amyotrophic lateral sclerosis (ALS) tells the nurse, "Sometimes I feel so frustrated. I can’t do anything without ...

Read more

NASM Flashcards

Which of the following is the process of getting oxygen from the environment to the tissues of the body? Diffusion ...

Read more

Unfinished tasks keep piling up?

Let us complete them for you. Quickly and professionally.

Check Price

Successful message
sending