CS1101 Unit 6 Quiz PDF

Title CS1101 Unit 6 Quiz
Course Programming Fundamentals
Institution University of the People
Pages 5
File Size 108.2 KB
File Type PDF
Total Downloads 30
Total Views 147

Summary

Download CS1101 Unit 6 Quiz PDF


Description

Self-quiz 6 review Question 1 What is the output of the following Python program? mylist = [ [2,4,1], [1,2,3], [2,3,5] ] total = 0 for sublist in mylist: total += sum(sublist) print(total) Select one: a. b. c. d.

14 23 0 13

The correct answer is: 23

Question 2 In Python, a list of characters is the same as a string. Select one: True False The correct answer is 'False'.

Question 3 String objects are modified with string slices. Select one: True False The correct answer is 'False'.

Question 4 The Python expression 'Unit 6'[-1] has value '6'. Select one: True False The correct answer is 'True'.

Question 5 What is the output of the following Python program? mylist = [ [2,4,1], [1,2,3], [2,3,5] ] a=0 total = 0 while a < 3: b=0 while b < 2: total += mylist[a][b] b += 1 a += 1 print(total) Select one: a. b. c. d.

14 23 0 13

The correct answer is: 14

Question 6 A variable that has a data type of "str" cannot be part of a compound data type Select one: True False The correct answer is 'False'.

Question 7 What is the output of the following Python program? index = "Ability is a poor man's wealth".find("W") print(index) Select one: a. b. c. d.

24 0 23 -1

Your answer is correct. The correct answer is: -1

Question 8 The elements of a list are immutable. Select one: True False The correct answer is 'False'.

Question 9 What is the output of the Python code below? my_list = [3, 2, 1] print(my_list) Select one: a. b. c. d. e.

0 {3, 2, 1} None syntax error [3, 2, 1]

The correct answer is: [3, 2, 1]

Question 10 What is the output of the following Python 3 program? mylist = ["now", "four", "is", "score", "the", "and seven", "time", "years", "for"] a=0 while a < 8: print(mylist[a],) a=a+2 Select one: a. b. c. d.

now is the time now is the time for four score and seven years now four is score the and seven time years for

The correct answer is: now is the time

Question 11 What is the output of the following Python program? mylist = ["now", "four", "is", "score", "the", "and seven", "time", "years", "for"] print(" ".join(mylist[1::2]))

Select one: a. now is the time b. now is the time for c. four score and seven years d. now four is score the and seven time years for The correct answer is: four score and seven years

Question 12 Traversal can only be accomplished with the "while" loop. Select one: True False The correct answer is:’False’.

Question 13 This Python code: for fruit in ["banana", "apple", "quince"]: print (fruit) Select one: True False The correct answer is 'False'.

Question 14 What is the output of the following Python program? index = "Ability is a poor man's wealth".find("w") print(index) Select one: a. b. c. d.

24 0 23 -1

Your answer is correct. The correct answer is: 24

Question 15 What is the output of the Python code below? my_list = [3, 2, 1]

print(my_list.sort()) Select one: a. b. c. d. e.

0 {1, 2, 3} None syntax error [1, 2, 3]

Your answer is correct. The correct answer is: None

Question 16 What is the output of the following Python program? fruit = "banana" letter = fruit[1] print (letter) Select one: a. b. c. d.

b a n banana

Your answer is correct. The correct answer is: a

Question 17 To create a new object that has the same value as an existing object is knows as creating an alias. Select one: True False The correct answer is 'False'....


Similar Free PDFs