CS 1101 Self-Quiz Unit 7 PDF

Title CS 1101 Self-Quiz Unit 7
Author Khoa Le
Course Programming Fundamentals
Institution University of the People
Pages 6
File Size 173.1 KB
File Type PDF
Total Downloads 118
Total Views 166

Summary

CS 1101 Self-Quiz Unit 7...


Description

Self-Quiz Unit 7

Question 1 Correct Mark 1.00 out of 1.00

Flag question Question text

What is the output of the Python code below? print(dict().get("no", "help!")) Select one: a. True b. no c. no help! d. help!

e. False Feedback Your answer is correct. The correct answer is: help!

Question 2 Correct Mark 1.00 out of 1.00

Flag question Question text

Assume that d is a Python dictionary. What does the following Python code produce? result = dict() for key in d: val = d[key] if val not in result: result[val] = [key]

else: result[val].append(key) Select one: a. a histogram b. an inverted dictionary

c. a list of tuples d. a lookup e. a reverse lookup Feedback Your answer is correct. The correct answer is: an inverted dictionary

Question 3 Correct Mark 1.00 out of 1.00

Flag question Question text

In the following segment of Python code, what do we call the portion of the statement that follows the dot('.capitalize')? str.capitalize('maryland') Select one: a. Module b. Method

c. Attribute d. Function name Feedback The correct answer is: Method

Question 4 Correct Mark 1.00 out of 1.00

Flag question Question text

Python functions can take a variable number of arguments. Select one: True

False Feedback The correct answer is 'True'.

Question 5 Correct Mark 1.00 out of 1.00

Flag question Question text

What is the value of the following Python expression? (0, 1, 5, 2) > (0, 1.0, 4, 3.1) Select one: a. 0 b. 1 c. False d. True

e. syntax error Feedback Your answer is correct. The correct answer is: True

Question 6 Correct

Mark 1.00 out of 1.00

Flag question Question text

Assume that d is a Python dictionary. What does the following Python code produce? d.items() Select one: a. a histogram b. an inverted dictionary c. a list of tuples

d. a lookup e. a reverse lookup Feedback Your answer is correct. The correct answer is: a list of tuples

Question 7 Correct Mark 1.00 out of 1.00

Flag question Question text

Traversal can only be accomplished with the "while" loop. Select one: True False

Feedback The correct answer is 'False'.

Question 8

Correct Mark 1.00 out of 1.00

Flag question Question text

Python tuples are immutable. Select one: True

False Feedback The correct answer is 'True'.

Question 9 Correct Mark 1.00 out of 1.00

Flag question Question text

What will the contents of mylist be after the following Python code has been executed? >>> mylist = [1, 4, 2, 3] >>> mylist.append(5) Select one: a. [1, 4, 2, 3, 5]

b. [5, 1, 4, 2, 3] c. [null] d. [1, 4, 2, 3] Feedback The correct answer is: [1, 4, 2, 3, 5]

Question 10

Correct Mark 1.00 out of 1.00

Flag question Question text

Given a Python dictionary d and a value v, it is efficient to find the corresponding key: d[k] = v. Select one: True False

Feedback The correct answer is 'False'....


Similar Free PDFs