Exercise: Data Types

Questions for: Data Types

What is the data type of the following value: {"a": 1, "b": 2, "c": 3}
A:
String
B:
List
C:
Tuple
D:
Dictionary
Answer: D
{"a": 1, "b": 2, "c": 3} is a dictionary in Python. Dictionaries are used to store key-value pairs, where each key maps to a corresponding value.
What is the data type of the following value: (1, 2, 3)
A:
String
B:
List
C:
Tuple
D:
Dictionary
Answer: C
(1, 2, 3) is a tuple in Python. Tuples are used to group together multiple values into a single immutable container.
Which of the following is a sequence data type?
A:
Dictionary
B:
Set
C:
Tuple
D:
None of the above
Answer: C
Tuples are a sequence data type in Python, meaning that their elements are ordered and indexed, and they can be accessed by their position in the sequence. Dictionaries and sets are not sequence data types, because they are unordered.
Which of the following is a mutable data type?
A:
String
B:
Tuple
C:
List
D:
Float
Answer: C
Lists are mutable in Python, meaning that their contents can be changed after they are created. Strings, tuples, and floats are all immutable, meaning that their contents cannot be changed after they are created.
What is the data type of the following value: "Hello, World!"
A:
String
B:
List
C:
Tuple
D:
Dictionary
Answer: A
"Hello, World!" is a string in Python. Strings are used to represent text data in Python.
Ad Slot (Above Pagination)
Quiz