Filters
Question type

Study Flashcards

The index of the last item in a list is the length of the list.

A) True
B) False

Correct Answer

verifed

verified

What happens if you attempt to pop a key from a dictionary and the key does not exist, and you specified no default return?


A) The pop will return a None value.
B) The pop will return a value of 0.
C) The pop will return a value of False.
D) An error will be raised.

E) B) and D)
F) B) and C)

Correct Answer

verifed

verified

The list method ascending mutates a list by arranging its elements in ascending order.

A) True
B) False

Correct Answer

verifed

verified

What dictionary method can be utilized to access the entries in a dictionary variable with a name of parts?


A) parts.list()
B) parts.items()
C) parts.print()
D) parts.show()

E) B) and C)
F) All of the above

Correct Answer

verifed

verified

An Identity function usually tests its argument for the presence or absence of some property.

A) True
B) False

Correct Answer

verifed

verified

In scripts that include the definitions of several cooperating functions, it is often useful to define a special function named init that serves as the entry point for the script.

A) True
B) False

Correct Answer

verifed

verified

If you use the range method with a single parameter of 50, what will be the range of integers included in the returned list?


A) 0 through 50
B) 0 through 49
C) 1 through 50
D) 1 through 49

E) A) and C)
F) B) and C)

Correct Answer

verifed

verified

Which of the following assigns a dictionary list of keys and values to the variable named persons?


A) persons = ["Sam":"CEO", "Julie":"President"]
B) persons = ("Sam":"CEO", "Julie":"President")
C) persons = {"Sam":"CEO", "Julie":"President"}
D) persons = {["Sam", "CEO"], ["Julie", "President"]}

E) C) and D)
F) None of the above

Correct Answer

verifed

verified

In a dictionary, a -> separates a key and its value.

A) True
B) False

Correct Answer

verifed

verified

What are the two arguments expected by the get method for a dictionary object? (Choose two.)


A) A possible key.
B) An index position.
C) A list of keys.
D) A default value.

E) A) and D)
F) A) and C)

Correct Answer

verifed

verified

What happens if you use the following statement to sort a list of numbers called numbers? numbers = numbers.sort()


A) numbers is a value of None
B) The list is now ordered in ascending order.
C) The list is now ordered in descending order.
D) The numbers variable becomes a reference to a sorted list.

E) B) and C)
F) None of the above

Correct Answer

verifed

verified

When replacing an element in a list, the subscript is used to reference the target of the assignment statement, which is not the list but an element's position within it.

A) True
B) False

Correct Answer

verifed

verified

When a Python script is running as a standalone program, what will the __name__ variable be set to?


A) The variable will hold the name of the script itself.
B) The variable will be set to "__main__".
C) The variable will be set to "standalone".
D) The variable will be set to "None".

E) A) and D)
F) B) and C)

Correct Answer

verifed

verified

Each item in a list has a unique index that specifies its position.

A) True
B) False

Correct Answer

verifed

verified

In order to create a docstring for a defined function, where should the docstring be?


A) The docstring should be just before the declaration of def.
B) The docstring should be placed at the end of the execution block for the function.
C) The docstring should be the next indented line after the def statement.
D) The docstring should be placed at the end of the function, before the return statement.

E) B) and C)
F) A) and D)

Correct Answer

verifed

verified

In a Python dictionary, an association is formed between what two components of the dictionary? (Choose two.)


A) lists
B) keys
C) values
D) indexes

E) All of the above
F) B) and D)

Correct Answer

verifed

verified

A list is a sequence of data values called indexes.

A) True
B) False

Correct Answer

verifed

verified

The definition of the main function and the other function definitions can appear in no particular order in the script, as long as main is called at the very end of the script.

A) True
B) False

Correct Answer

verifed

verified

Although a list's elements are always ordered by position, it is possible to impose a natural ordering on them as well.

A) True
B) False

Correct Answer

verifed

verified

To prevent aliasing, a new object can be created and the contents of the original can be copied to it.

A) True
B) False

Correct Answer

verifed

verified

Showing 21 - 40 of 50

Related Exams

Show Answer