Sign Up Free

Python Programming: Which One Doesn't Belong

Odd One Out 15 questions Computer Science & Technology > Python by steven marone
Study this material interactively with flashcards, quizzes, and games on GabaBrain.
Study on GabaBrain

Odd One Out (15)

Question 1
Which of these Python data types is not mutable?
  • list
  • dict
  • tuple ✓
  • set
Correct Answer
tuple
The shared property is being a mutable data type. list, dict, and set are all mutable, meaning their contents can be changed after creation. A tuple is immutable; its elements cannot be changed once it is created.
Question 2
Which of these Python keywords is not primarily used to define a looping construct?
  • while
  • elif
  • if ✓
  • for
Correct Answer
if
The shared property is being a Python keyword primarily used to define a looping construct. for and while are used to define loops. if is used to define a conditional statement, not a loop. elif is also part of conditional statements.
Question 3
Which of these is not a Python list method that modifies the list in place?
  • append
  • count ✓
  • sort
  • reverse
Correct Answer
count
The shared property is being a Python list method that modifies the list in place. append adds an element, sort sorts the list, and reverse reverses the order, all directly changing the list object. count returns the number of occurrences of an element and does not modify the list.
Question 4
Which of these Python built-in functions is not primarily used for type conversion?
  • float
  • int
  • type ✓
  • str
Correct Answer
type
The shared property is being a Python built-in function primarily used for type conversion. int, str, and float are used to convert values to integer, string, and float types, respectively. type returns the type of an object but does not convert the object itself to a new type.
Question 5
Which of these Python dictionary methods does not return a view object?
  • values
  • items
  • keys
  • get ✓
Correct Answer
get
The shared property is being a Python dictionary method that returns a view object. keys, values, and items return dynamic views of the dictionary's keys, values, or key-value pairs, respectively. get retrieves the value for a given key and returns that value, not a view object.
Question 6
Which of these is not a Python keyword that defines a block in exception handling?
  • raise ✓
  • try
  • finally
  • except
Correct Answer
raise
The shared property is being a Python keyword that defines a block in exception handling. try, except, and finally are blocks that structure exception handling. raise is a statement used to explicitly trigger an exception, not to define a block.
Question 7
Which of these Python file handling modes is not typically used to open a file for writing?
  • r ✓
  • a
  • w
  • x
Correct Answer
r
The shared property is being a Python file handling mode typically used to open a file for writing. 'w' (write), 'a' (append), and 'x' (exclusive creation) are all modes that allow writing to a file. 'r' is used to open a file for reading only.
Question 8
Which of these is not a Python keyword used to define a function or its behavior?
  • lambda
  • pass ✓
  • def
  • return
Correct Answer
pass
The shared property is being a Python keyword used to define a function or its behavior. def defines a function, return specifies its output, and lambda creates anonymous functions. pass is a null operation statement; it can be used as a placeholder in a function body but does not define the function or its behavior.
Question 9
Which of these Python built-in functions is not typically used to work with iterables for aggregation or transformation?
  • map
  • sorted
  • sum
  • len ✓
Correct Answer
len
The shared property is being a Python built-in function typically used to work with iterables for aggregation or transformation, producing a new iterable or a single aggregate value based on the elements. sum aggregates elements, map transforms elements, and sorted produces a new sorted list. len returns the number of items in an iterable, which is an inspection/property, not an aggregation or transformation of the elements themselves.
Question 10
Which of these Python control flow keywords is not used to alter the normal execution flow within a loop?
  • return ✓
  • break
  • continue
  • pass
Correct Answer
return
The shared property is being a Python control flow keyword used to alter the normal execution flow within a loop. break exits the loop entirely, and continue skips the current iteration. pass is a null operation and does not alter the flow. return exits the current function, which might contain a loop, but its primary purpose is not to control the loop's internal flow.
Question 11
Which of these Python sequence types is not immutable?
  • str
  • list ✓
  • bytes
  • tuple
Correct Answer
list
The shared property is being an immutable sequence type. tuple, str, and bytes are all immutable sequences, meaning their elements cannot be changed after creation. list is a mutable sequence type.
Question 12
Which of these is not a common way to iterate over elements in a Python list along with their indices?
  • for i, _ in enumerate(my_list):
  • for index, item in enumerate(my_list):
  • for item in my_list: ✓
  • for i in range(len(my_list)):
Correct Answer
for item in my_list:
The shared property is being a common way to iterate over elements in a Python list along with their indices. The options using range(len(my_list)) and enumerate provide access to both the index (i or index) and the item. The 'for item in my_list:' loop iterates only over the items, without direct access to their indices.
Question 13
Which of these Python built-in exceptions is not typically raised due to an invalid key or index access or iteration completion?
  • TypeError ✓
  • StopIteration
  • IndexError
  • KeyError
Correct Answer
TypeError
The shared property is being a Python built-in exception typically raised due to an invalid key or index access or iteration completion. IndexError is raised for an invalid sequence index, KeyError for an invalid dictionary key, and StopIteration signals the end of an iterator. TypeError is raised when an an operation or function is applied to an object of an inappropriate type, not specifically due to an invalid key or index.
Question 14
Which of these operations on a Python file object is not generally considered a 'read' operation?
  • read()
  • readline()
  • readlines()
  • write() ✓
Correct Answer
write()
The shared property is being an operation on a Python file object that reads data from the file. read(), readline(), and readlines() all retrieve content from the file. write() is an operation that sends data to the file, not reads it.
Question 15
Which of these Python built-in functions does not return a single value when applied to an iterable?
  • max
  • sorted ✓
  • min
  • sum
Correct Answer
sorted
The shared property is being a Python built-in function that operates on any iterable and returns a single numerical value (an aggregate). sum, min, and max all take an iterable and return a single numerical value (total, smallest, or largest). sorted takes an iterable but returns a new list (another iterable), not a single numerical value.

Ready to study Python Programming: Which One Doesn't Belong?

Study with flashcards, play quiz games, challenge your friends, and track your progress.

Start Studying Free