ITP Chapter 10

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

list-11-3: What is printed by the following statements? alist = [4, 2, 8, 6, 5] blist = alist blist[3] = 999 print(alist) A. [4, 2, 8, 6, 5] B. [4, 2, 8, 999, 5]

B

list-14-5: What is printed by the following statements? alist = [4, 2, 8, 6, 5] temp = alist.pop(2) temp = alist.pop() print(alist) A. [4, 8, 6] B. [2, 6, 5] C. [4, 2, 6]

C

list-14-4: What is printed by the following statements? alist = [4, 2, 8, 6, 5] alist.insert(2, True) alist.insert(0, False) print(alist) A. [False, 4, 2, True, 8, 6, 5] B. [4, False, True, 2, 8, 6, 5] C. [False, 2, True, 6, 5]

A

list-2-2: A list can contain only integer items. A. False B. True

A

list-3-3: What is printed by the following statements? alist = [3, 67, "cat", [56, 57, "dog"], [ ], 3.14, False] print(len(alist)) A. 7 B. 8

A

list-5-2: What is printed by the following statements? alist = [3, 67, "cat", [56, 57, "dog"], [ ], 3.14, False] print(3.14 in alist) A. True B. False

A

list-7-2: What is printed by the following statements? alist = [3, 67, "cat", [56, 57, "dog"], [ ], 3.14, False] print(alist[4:]) A. [ [ ], 3.14, False] B. [ [ ], 3.14] C. [ [56, 57, "dog"], [ ], 3.14, False]

A

list-11-4: Consider the following lists: list1=[1,100,1000] list2=[1,100,1000] list3=list1 Which statements will output True? (Select all that apply). A. print(list1 == list2) B. print(list1 is list2) C. print(list1 is list3) D. print(list2 is not list3) E. print(list2 != list3)

A, C, D

list-13-6: What is printed by the following statements? alist = [4, 2, 8, 6, 5] blist = [alist] * 2 alist[3] = 999 print(blist) A. [4, 2, 8, 999, 5, 4, 2, 8, 999, 5] B. [[4, 2, 8, 999, 5], [4, 2, 8, 999, 5]] C. [4, 2, 8, 6, 5] D. [[4, 2, 8, 999, 5], [4, 2, 8, 6, 5]]

B

list-14-3: What is printed by the following statements? alist = [4, 2, 8, 6, 5] alist.append(True) alist.append(False) print(alist) A. [4, 2, 8, 6, 5, False, True] B. [4, 2, 8, 6, 5, True, False] C. [True, False, 4, 2, 8, 6, 5]

B

list-16-4: What is printed by the following statements? alist = [4, 2, 8, 6, 5] alist = alist + 999 print(alist) A. [4, 2, 8, 6, 5, 999] B. Error, you cannot concatenate a list with an integer.

B

list-29-9: What is printed by the following statements? s = "We are learning!" x = 0 for i in s: if i in ['a', 'b', 'c', 'd', 'e']: x += 1 print(x) A. 2 B. 5 C. 0 D. There is an error in the code so it cannot run.

B

list-3-2: What is printed by the following statements? alist = [3, 67, "cat", 3.14, False] print(len(alist)) A. 4 B. 5

B

list-4-2: What is printed by the following statements? alist = [3, 67, "cat", [56, 57, "dog"], [ ], 3.14, False] print(alist[5]) A. [ ] B. 3.14 C. False

B

list-4-4: What is printed by the following statements? alist = [3, 67, "cat", [56, 57, "dog"], [ ], 3.14, False] print(alist[2][0]) A. 56 B. c C. cat D. Error, you cannot have two index values unless you are using slicing.

B

list-5-3: What is printed by the following statements? alist = [3, 67, "cat", [56, 57, "dog"], [ ], 3.14, False] print(57 in alist) A. True B. False

B

list-8-6: What is printed by the following statements? alist = [4, 2, 8, 6, 5] alist[2] = True print(alist) A. [4, 2, True, 8, 6, 5] B. [4, 2, True, 6, 5] C. Error, it is illegal to assign

B

list-13-5: What is printed by the following statements? alist = [4, 2, 8, 6, 5] blist = alist * 2 blist[3] = 999 print(alist) A. [4, 2, 8, 999, 5, 4, 2, 8, 6, 5] B. [4, 2, 8, 999, 5] C. [4, 2, 8, 6, 5]

C

list-14-6: What is printed by the following statements? alist = [4, 2, 8, 6, 5] alist = alist.pop(0) print(alist) A. [2, 8, 6, 5] B. [4, 2, 8, 6, 5] C. 4 D. None

C

list-17-5: What is printed by the following statements? alist = [4, 2, 8, 6, 5] blist = [ ] for item in alist: blist.append(item+5) print(blist) A. [4, 2, 8, 6, 5] B. [4, 2, 8, 6, 5, 5] C. [9, 7, 13, 11, 10] D. Error, you cannot concatenate inside an append.

C

list-23-2: What is printed by the following statements? alist = [ [4, [True, False], 6, 8], [888, 999] ] if alist[0][1][0]: print(alist[1][0]) else: print(alist[1][1]) A. 6 B. 8 C. 888 D. 999

C

list-24-4: What is printed by the following statements? myname = "Edgar Allan Poe" namelist = myname.split() init = "" for aname in namelist: init = init + aname[0] print(init) A. Poe B. EdgarAllanPoe C. EAP D. William Shakespeare

C

list-29-10: What is printed by the following statements? list= [5, 2, 1, 4, 9, 10] min_value = 0 for item in list: if item < min_value: min_value = item print(min_value) A. 10 B. 1 C. 0 D. There is an error in the code so it cannot run.

C

list-4-3: What is printed by the following statements? alist = [3, 67, "cat", [56, 57, "dog"], [ ], 3.14, False] print(alist[2].upper()) A. Error, you cannot use the upper method on a list. B. 2 C. CAT

C

list-6-3: What is printed by the following statements? alist = [1, 3, 5] blist = [2, 4, 6] print(alist + blist) A. 6 B. [1, 2, 3, 4, 5, 6] C. [1, 3, 5, 2, 4, 6] D. [3, 7, 11]

C

list-6-4: What is printed by the following statements? alist = [1, 3, 5] print(alist * 3) A. 9 B. [1, 1, 1, 3, 3, 3, 5, 5, 5] C. [1, 3, 5, 1, 3, 5, 1, 3, 5] D. [3, 9, 15]

C

list-22-3: What is printed by the following statements? alist = [4,2,8,6,5] blist = [num*2 for num in alist if num%2==1] print(blist) A. [4,2,8,6,5] B. [8,4,16,12,10] C. 10 D. [10].

D


Ensembles d'études connexes

Essentials of Investments: Chapter 10

View Set

2.5 Roadways and Their Unique Risks

View Set

Ch4 Analysing the marketing environment.

View Set

Final COMP 530 - Operating Systems

View Set