Chapter 4 - Self-Test Questions

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

Which one of the following is NOT a common operation on lists? a. access b. replace c. interleave d. append e. insert f. delete

c

Lists and tuples must each contain at least one element. True/False

False

For fruit = 'strawberry', what does the following for loop output? for k in range(0, len(fruit), 2): print(k) a. srwer b. tabry

a

For lst = [4, 2, 9, 1], what is the result of the following operation, lst.insert(2, 3)? a. [4, 2, 3, 9, 1] b. [4, 3, 2, 9, 1] c. [4, 2, 9, 2, 1]

a

What would be the range of index values for a list of 10 elements? a. 0-9 b. 0-10 c. 1-10

a

Which of the following set of operations can be applied to any sequence type? a. len(s), s[i], s + w (concatenation) b. max(s), s[i], sum(s) c. len(s), s[i], s.sort()

a

For nums = [10, 30, 20, 40], what does the following for loop output? for k in nums: print(k) a. [10, 20, 30, 40] b. [10, 30, 20, 40] c. [10, 30, 20]

b

For nums = [10, 30, 20, 40], what does the following for loop output? for k in range(1, 4): print(k) a. [10, 30, 20] b. [30, 20, 40] c. [10, 30, 20, 40]

b

For nums = [12, 4, 11, 23, 18, 41, 27], what is the value of k when the while loop terminates? k = 0 while k < len(nums) and nums[k] != 18: k = k + 1 a. 3 b. 4 c. 5

b

Which of the following is true? a. Lists and tuples are denoted by the use of square brackets. b. Lists are denoted by the use of square brackets and tuples are denoted by the use of parentheses. c. Lists are denoted by the use of parentheses and tuples are denoted by square brackets.

b

Which of the following sequences is a mutable type? a. strings b. lists c. tuples

b

Which of the following would be the resulting list after inserting the value 50 at index 2? original = [35, 15, 45, 28] a. [35, 50, 15, 45, 28] b. [35, 15, 50, 45, 28] c. [50, 35, 15, 45, 28]

b

Which of the following is the correct way to denote a tuple of one element? a. [6] b. (6) c. [6,] d. (6,)

d


Ensembles d'études connexes

Title VII of the Civil Rights Act of 1964

View Set

Where did the first peoples to the Americas come from?

View Set

Advanced Expert Unit 1(1-99) i 2 moje

View Set

français 3, section 2, grammaire quiz 1

View Set

Introduction to the Von Neumann Architecture

View Set

MKT 3013 Chapter 10: Marketing Channels: Delivering Customer Value

View Set

Saunders NCLEX RN - Eyes & Ears Medication Pharmacology

View Set

Honors Algebra II: 5.1, 6.1, 6.2, and 6.6 Review

View Set