Python Data Types Questions and Answers

Practice Mode
Showing 10 of 24 questions
Q1
Which of the following is a mutable data type in Python?
  • A tuple
  • B string
  • C list
  • D int
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([]))
  • A <class 'str'>
  • B <class 'list'>
  • C <class 'tuple'>
  • D <class 'dict'>
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?
  • A list
  • B tuple
  • C set
  • D dictionary
Answer: Option C
Explanation: Sets in Python are unordered collections of unique elements.
Q4
What does the following code return: bool("False")
  • A False
  • B True
  • C Error
  • D None
Answer: Option B
Explanation: Any non-empty string evaluates to True in boolean context.
Q5
Which of these is an immutable sequence type?
  • A list
  • B dictionary
  • C set
  • D tuple
Answer: Option D
Explanation: Tuples are immutable sequences, while lists are mutable sequences.
Q6
What is the data type of (1,)?
  • A int
  • B tuple
  • C list
  • D str
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?
  • A get_keys()
  • B keys()
  • C all_keys()
  • D dict_keys()
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
  • A 7
  • B 7.5
  • C Error
  • D None
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?
  • A {}
  • B []
  • C ()
  • D set()
Answer: Option D
Explanation: Sets are created with curly braces {} or the set() constructor.
Q10
What does None represent in Python?
  • A 0
  • B False
  • C Null value
  • D Empty string
Answer: Option C
Explanation: None is a special constant representing the absence of a value or a null value.
Questions and Answers for Competitive Exams Various Entrance Test