Python Programming - Data Types

Exercise : Data Types - General Questions
  • Data Types - General Questions
6.
Which of the following is not a numeric data type?
int
float
complex
bool
Answer: Option
Explanation:
While boolean values (True and False) are a fundamental data type in Python, they are not considered a numeric data type. Integers, floats, and complex numbers are numeric data types in Python.

7.
Which of the following data types is used to represent a collection of elements with no duplicates?
List
Tuple
Set
Dictionary
Answer: Option
Explanation:
Sets are used to represent a collection of elements with no duplicates. Lists and tuples can contain duplicate elements, while dictionaries are used to store key-value pairs.

8.
Which of the following data types is used to represent a collection of key-value pairs?
List
Tuple
Set
Dictionary
Answer: Option
Explanation:
Dictionaries are used to represent a collection of key-value pairs, where each key maps to a corresponding value. Lists, tuples, and sets do not have this structure.

9.
Which of the following data types is used to represent a sequence of characters?
bytearray
bytes
complex
str
Answer: Option
Explanation:

The bytearray data type is used to represent a mutable sequence of bytes, rather than characters. While a bytearray can hold character data, it is not specifically designed to represent a sequence of characters like the str data type.

The bytes data type in Python is used to represent a sequence of bytes. It is similar to the bytearray data type, but it is immutable, meaning it cannot be changed after it is created. While the bytes type can hold character data, it is not specifically designed to represent a sequence of characters like the str data type.

The complex data type in Python is used to represent complex numbers, which are numbers with a real and imaginary part (e.g., 3 + 4j). This data type is not used to represent a sequence of characters, but rather to work with complex mathematical operations involving real and imaginary numbers.

The str type is the standard way to represent sequences of characters in Python.


10.
Which of the following data types is used to represent a sequence of ordered elements that can be modified?
List
Tuple
Set
Dictionary
Answer: Option
Explanation:
Lists are used to represent a sequence of ordered elements that can be modified, such as adding or removing elements. Tuples are also a sequence data type, but they are immutable and cannot be modified after creation. Sets and dictionaries are not sequence data types.