Python Data Types Questions and Answers
Practice ModeShowing 10 of 24 questions
Q1
Which of the following is a mutable data type in Python?
Answer: Option C
Explanation: Lists and dictionaries are mutable, meaning their content can be changed after creation.
Q2
What is the output of: print(type([]))
Answer: Option B
Explanation: The square brackets [] create a list object in Python.
Q3
Which data type would be most appropriate for storing a collection of unique items?
Answer: Option C
Explanation: Sets in Python are unordered collections of unique elements.
Q4
What does the following code return: bool("False")
Answer: Option B
Explanation: Any non-empty string evaluates to True in boolean context.
Q5
Which of these is an immutable sequence type?
Answer: Option D
Explanation: Tuples are immutable sequences, while lists are mutable sequences.
Q6
What is the data type of (1,)?
Answer: Option B
Explanation: A tuple with single element requires a trailing comma.
Q7
Which method would you use to get all keys from a dictionary?
Answer: Option B
Explanation: The keys() method returns a view object of all keys in a dictionary.
Q8
What is the result of: 3 + 4.5
Answer: Option B
Explanation: Python automatically converts int to float when performing arithmetic with mixed types.
Q9
Which of these creates a set in Python?
Answer: Option D
Explanation: Sets are created with curly braces {} or the set() constructor.
Q10
What does None represent in Python?
Answer: Option C
Explanation: None is a special constant representing the absence of a value or a null value.