ch9 python coding Qs

¡Supera tus tareas y exámenes ahora con Quizwiz!

After the following code executes, what elements will be members of set3? set1 = set(['d', 'e', 'f']) set2 = set(['a', 'b', 'c', 'd', 'e']) set3 = set2.difference(set1)

{'c', 'a', 'b'}

After the following code executes, what elements will be members of set3? set1 = set([1, 2, 3]) set2 = set([2, 3, 4]) set3 = set1.symmetric_difference(set2)

{1, 4}

What will the following code display? dct = {'Monday':1, 'Tuesday':2, 'Wednesday':3} print(dct.get('Monday', 'Not found'))

1

What values will the following code display? (Don't worry about the order in which they will be displayed.) dct = {1:[0, 1], 2:[2, 3], 3:[4, 5]} for k in dct: print(k) ***

1 2 3 might be wrong

Look at the following code: set1 = set([100, 200, 300, 400, 500]) set2 = set([200, 400, 500]) Which of the sets is a subset of the other? Which of the sets is a superset of the other?

set1 is a superset set2 is a subset

What will the following code display? dct = {'Monday':1, 'Tuesday':2, 'Wednesday':3} print(dct['Tuesday'])

2

After the following statement executes, what elements will be stored in the myset set? myset = set([2, 4, 4, 6, 6, 6, 6])

2, 4, 6

What will the following code display? stuff = {'aaa' : 111, 'bbb' : 222, 'ccc' : 333} print(stuff['bbb'])

222

After the following statement executes, what elements will be stored in the myset set? myset = set('Saturn')

'S','a','t','u','r','n'

After the following statement executes, what elements will be stored in the myset set? myset = set('a bb ccc dddd')

'b', 'd', 'c', ' ', 'a'

After the following statement executes, what elements will be stored in the myset set? myset = set(['a', 'bb', 'ccc', 'dddd'])

'dddd', 'a', 'ccc', 'bb'

What will the following code display? myset = set('1 2 3') print(len(myset))

4

After the following code executes, what elements will be members of set3? set1 = set([10, 20, 30, 40]) set2 = set([40, 50, 60]) set3 = set1.union(set2)

50, 20, 40, 10, 60, 30

After the following statement executes, what elements will be stored in the myset set? myset = set(10)

TypeError: 'int' object is not iterable

What will the following code display? dct = {1:[0, 1], 2:[2, 3], 3:[4, 5]} print(dct[3])

[4,5]

What will the following code display? dct = {'Monday':1, 'Tuesday':2, 'Wednesday':3} print(dct.get('Friday', 'Not found'))

not found


Conjuntos de estudio relacionados

Med Surg Exam 4: Combined Starred Terms

View Set

Fundamentals Module 1 Lesson 3 Quiz

View Set

Ch. 4 - Neuron Structure and Function

View Set

F260 Financial Services: Savings Plans and Payment Accounts

View Set

Policy Provisions and Contract Law

View Set

Domain IV: Food and Nutrition Systems

View Set