Chapters 7,8 and 9

Your page rank:

Total word count: 785
Pages: 3

Calculate the Price

- -
275 words
Looking for Expert Opinion?
Let us have a look at your work and suggest how to improve it!
Get a Consultant

Which function would you use to get the number of elements in a dictionary?

len

What method can be used to convert a tuple to a list?

list

What is the number of the first index in a list dictionary?

dictionary is not indexed by number

What would be the value of the variable list after the execution of the following code?

list = [1, 2]

list = list * 3

[1, 2, 1, 2, 1, 2]

What will be assigned to s_string after the execution of the following code?

special = ‘1357 Country Ln.’

s_string = special[ :4]

‘1357’

What method can be used to place an item in the list at a specific index?

insert

The primary difference between a tuple and list is that ________.

once a tuple is created, it cannot be changed

What is the correct structure for creating a dictionary of month names to be accessed by month numbers?

{ 1 : ‘January’, 2 : ‘February’, 3 : ‘March’ }

What would you use if an element is to be removed from a specific index?

del statement

What would be the value of the variable list2 after the execution of the following code?

list1 = [1, 2, 3]
list2 = [ ]
for element in list1:
list2.append(element)
list1 = [4, 5, 6]

[1, 2, 3]

Which list will be referenced by the variable number after the execution of the following code?

[0, 2, 4, 6, 8]

Which method would you use to determine whether a substring is present in a string?

find(substring)

What would be the result of the following code?

ages = {‘Aaron’ : 6, ‘Kelly’ : 3, ‘Abigail’ : 1}
value = ages[‘Brianna’]

KeyError

What is the value of the variable phones after the execution of the following code?

phones = {‘John’: ‘5555555’, ‘Julie’: ‘7777777’}

phones[‘John’] = ‘1234567’

{‘John’: ‘1234567’, ‘Julie’ : ‘7777777’}

What is the value of the variable string after the execution of the following code?

string = ‘Hello’

string += ‘ world’

‘Hello world’

What would be the value of the variable list after the execution of the following code?

list = [1, 2, 3, 4]

list[3] = 10

[1, 2, 3, 10]

Which statement would you use to delete an existing key-value pair from a dictionary?

del

In order to avoid KeyError exceptions, you can check whether a key is in the dictionary using the ________ operator.

in

What method or operator can be used to concatenate lists?

+

What method can be used to convert a list to a tuple?

tuple

Which method would you use to return the value associated with a specified key and remove that key-value pair from the dictionary?

pop

True/False: Lists are dynamic data structures such that items may be added to them or removed from them.

true

What is the value of the variable string after the execution of the following code?

string = ‘abcd’
string = string.upper()

‘ABCD’

Which of the following does not apply to sets?

All the elements must be unique—no two elements can have the same value.

True/False: A list cannot be passed as an argument to a function.

false

In a dictionary, you use a(n) ________ to locate a specific value.

key

You created the following dictionary relationships = {‘Jimmy’:’brother’}. You then executed the following code, and received a KeyError exception. What is the reason for the exception?

relationships[‘jimmy’]

string comparisons are case sensitive so ‘jimmy’ does not equal ‘Jimmy’

What is the process used to convert an object to a stream of bytes that can be saved in a file?

pickling

What will be assigned to the string variable even after the execution of the following code?

special = ‘0123456789’

even = special[0:10:2]

‘02468’

True/False: By default, the sort method rearranges the elements of a list so they appear in ascending or descending order.

false

What will be assigned to the string variable pattern after the execution of the following code?

i = 3

pattern = ‘z’ <b> (5</b>i)

‘zzzzzzzzzzzzzzz’

When working with multiple sets of data, one would typically use a ________.

nested list

True/False: Indexing starts at 1, so the index of the first element is 1, the index of the second element is 2, and so forth.

false

What are the data items in the list called?

elements

True/False: The remove method removes all occurrences of the item from a list.

false

What will be assigned to s_string after the execution of the following code?

special = ‘1357 Country Ln.’

s_string = special[4: ]

‘ Country Ln.’

What are the valid indexes for the string ‘New York’?

0 through 7

What would be the value of the variable list2 after the execution of the following code?

list1 = [1, 2, 3]

list2 = list1

list1 = [4, 5, 6]

[1, 2, 3]

Which list will be referenced by the variable list_string after the execution of the following code?

list_string = ’03/07/2008′

list_string = list_string.split(‘/’)

[’03’, ’07’, ‘2008’]

What method can be used to add a group of elements to a set?

update

Share This
Flashcard

More flashcards like this

NCLEX 10000 Integumentary Disorders

When assessing a client with partial-thickness burns over 60% of the body, which finding should the nurse report immediately? a) ...

Read more

NCLEX 300-NEURO

A client with amyotrophic lateral sclerosis (ALS) tells the nurse, "Sometimes I feel so frustrated. I can’t do anything without ...

Read more

NASM Flashcards

Which of the following is the process of getting oxygen from the environment to the tissues of the body? Diffusion ...

Read more

Unfinished tasks keep piling up?

Let us complete them for you. Quickly and professionally.

Check Price

Successful message
sending