KEMBAR78
Data Types | PDF | Boolean Data Type | Integer (Computer Science)
0% found this document useful (0 votes)
24 views25 pages

Data Types

The document contains 100 multiple-choice questions (MCQs) focused on Python's data types, covering built-in types such as int, str, float, and complex, as well as their properties like mutability and order. Each question presents a specific aspect of Python data types, with four answer options provided for selection. The document serves as a comprehensive quiz for testing knowledge on Python data types.

Uploaded by

mehzar zehra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views25 pages

Data Types

The document contains 100 multiple-choice questions (MCQs) focused on Python's data types, covering built-in types such as int, str, float, and complex, as well as their properties like mutability and order. Each question presents a specific aspect of Python data types, with four answer options provided for selection. The document serves as a comprehensive quiz for testing knowledge on Python data types.

Uploaded by

mehzar zehra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

100 multiple‐choice questions (MCQs) on Python’s Data Types

Q1. Which of the following is a built-in Python data type?


A) int
B) str
C) float
D) All of the above
Answer: D

Q2. Which Python data type represents whole numbers?


A) int
B) float
C) complex
D) bool
Answer: A

Q3. Which data type is used to represent numbers with a fractional part?
A) int
B) float
C) bool
D) str
Answer: B

Q4. Which Python data type represents complex numbers?


A) int
B) float
C) complex
D) bool
Answer: C

Q5. Which of the following data types is used to represent textual data?
A) int
B) str
C) list
D) bool
Answer: B

Q6. Which of the following is ordered and immutable?


A) list
B) tuple
C) set
D) dict
Answer: B

Q7. Which data type is mutable?


A) str
B) tuple
C) list
D) frozenset
Answer: C

Q8. Which data type is an unordered mutable collection?


A) list
B) tuple
C) set
D) str
Answer: C

Q9. Which built-in data type stores key-value pairs?


A) set
B) list
C) tuple
D) dict
Answer: D

Q10. What is the type of the special value None in Python?


A) NoneType
B) null
C) void
D) UndefinedType
Answer: A

Q11. Which data type is used to represent truth values in Python?


A) bool
B) int
C) str
D) float
Answer: A

Q12. What value does bool('') (an empty string) return?


A) True
B) False
C) None
D) Error
Answer: B

Q13. Which of the following is NOT mutable in Python?


A) list
B) dict
C) tuple
D) set
Answer: C

Q14. Which data type is commonly used to store multiple items in a single variable?
A) list
B) int
C) bool
D) NoneType
Answer: A

Q15. Which of the following types is considered a sequence in Python?


A) str
B) set
C) dict
D) NoneType
Answer: A

Q16. Which of these is a valid way to declare an empty list?


A) []
B) {}
C) ()
D) <>
Answer: A
Q17. Which is a valid way to declare an empty dictionary?
A) []
B) ()
C) {}
D) set()
Answer: C

Q18. Which data type does not support indexing?


A) list
B) str
C) dict
D) tuple
Answer: C

Q19. Which of the following is immutable?


A) list
B) dict
C) set
D) str
Answer: D

Q20. Which is best for storing a collection of unique elements?


A) tuple
B) set
C) str
D) int
Answer: B
Q21. What is the data type of the expression 3 + 2j in Python?
A) int
B) float
C) complex
D) tuple
Answer: C

Q22. Which built-in type maintains insertion order (as of Python 3.7) when used to store key-value pairs?
A) list
B) tuple
C) dict
D) set
Answer: C

Q23. What is returned by type('Hello')?


A) <class 'str'>
B) <class 'int'>
C) <class 'list'>
D) <class 'dict'>
Answer: A

Q24. Which data type is best for representing a person’s name?


A) int
B) float
C) str
D) bool
Answer: C

Q25. Which of the following is a valid complex number literal in Python?


A) 1+2
B) 1+2j
C) j+2
D) 1j2
Answer: B

Q26. What is the result of bool(0)?


A) True
B) False
C) 0
D) Error
Answer: B

Q27. Which of the following is a correct floating point literal?


A) 3
B) 3.0
C) 3j
D) '3'
Answer: B

Q28. Which data type stores a sequence of Unicode characters?


A) bytes
B) bytearray
C) str
D) complex
Answer: C

Q29. What is the output of type(4.5)?


A) <class 'int'>
B) <class 'float'>
C) <class 'complex'>
D) <class 'str'>
Answer: B

Q30. How do you create a tuple with a single element?


A) (1)
B) (1,)
C) [1]
D) {1}
Answer: B

Q31. What is the default data type for numeric literals like 42?
A) int
B) float
C) str
D) complex
Answer: A

Q32. Which built-in type represents a sequence of bytes?


A) str
B) bytes
C) list
D) dict
Answer: B

Q33. What is the result of type(True)?


A) <class 'bool'>
B) <class 'int'>
C) <class 'str'>
D) <class 'NoneType'>
Answer: A

Q34. Which of the following is NOT true about Python sets?


A) They are unordered.
B) They contain no duplicate items.
C) They are indexed.
D) They are mutable (contain immutable elements).
Answer: C

Q35. Which data type inherently prevents duplicate values?


A) list
B) set
C) tuple
D) dict values
Answer: B

Q36. What does type([]) return?


A) <class 'list'>
B) <class 'tuple'>
C) <class 'dict'>
D) <class 'set'>
Answer: A

Q37. What is the output of type(())?


A) <class 'list'>
B) <class 'tuple'>
C) <class 'dict'>
D) <class 'set'>
Answer: B

Q38. Which data type is used to store key-value pairs with unique keys?
A) tuple
B) list
C) dict
D) set
Answer: C

Q39. Which is the correct way to create a set with the elements 1, 2, and 3?
A) {1, 2, 3}
B) [1, 2, 3]
C) (1, 2, 3)
D) <1, 2, 3>
Answer: A

Q40. Which data type represents an immutable sequence of characters?


A) list
B) dict
C) str
D) set
Answer: C

Q41. What is the data type of the literal 'True' (including quotes)?
A) bool
B) str
C) int
D) NoneType
Answer: B

Q42. The literal 3.14 is of which data type?


A) int
B) float
C) complex
D) str
Answer: B

Q43. What data type does the input() function return?


A) int
B) float
C) str
D) bool
Answer: C

Q44. Which keyword denotes a null value in Python?


A) null
B) void
C) None
D) nil
Answer: C

Q45. Which statement is true about Python’s int type?


A) It has fixed precision.
B) It supports arbitrary (unlimited) precision.
C) It only supports 32-bit integers.
D) It only supports signed integers.
Answer: B
Q46. Which data type represents a binary sequence of data?
A) str
B) bytes
C) list
D) int
Answer: B

Q47. What does type({}) return by default?


A) <class 'dict'>
B) <class 'set'>
C) <class 'list'>
D) <class 'tuple'>
Answer: A

Q48. Which data type is used for a modifiable sequence of elements?


A) tuple
B) list
C) str
D) frozenset
Answer: B

Q49. What does the type() function return when called on a variable?
A) The variable’s name
B) The data type of its value
C) Its memory address
D) The variable’s value
Answer: B
Q50. Which of the following is a valid dictionary in Python?
A) {1, 2, 3}
B) [1, 2, 3]
C) {'a': 1, 'b': 2}
D) (1, 2, 3)
Answer: C

Q51. Which type supports slicing operations?


A) int
B) float
C) str
D) bool
Answer: C

Q52. Which data type stores an ordered collection of items?


A) list
B) set
C) dict (keys only are unordered)
D) None of the above
Answer: A

Q53. Which built-in operator returns the data type of a variable?


A) typeof
B) istype
C) type()
D) datatype()
Answer: C

Q54. Which data type is best for representing a fixed collection of items?
A) list
B) tuple
C) set
D) dict
Answer: B

Q55. Which data type represents Unicode encoded text in Python 3?


A) unicode
B) str
C) bytes
D) char
Answer: B

Q56. What does type(3) return?


A) <class 'int'>
B) <class 'float'>
C) <class 'complex'>
D) <class 'str'>
Answer: A

Q57. Which of the following is hashable in Python?


A) list
B) dict
C) tuple
D) set
Answer: C

Q58. What is a key characteristic of Python tuples?


A) They are mutable.
B) They are ordered.
C) They allow duplicate keys.
D) They are unordered.
Answer: B

Q59. What is the type of the literal (1, 2, 3)?


A) list
B) tuple
C) dict
D) set
Answer: B

Q60. Which data type is used for immutable byte sequences?


A) str
B) bytes
C) bytearray
D) memoryview
Answer: B

Q61. Which data type is implemented internally as a hash table?


A) list
B) tuple
C) set
D) None of the above
Answer: C

Q62. How can you create an empty tuple?


A) ()
B) []
C) {}
D) <empty>
Answer: A

Q63. Which data type is best for storing a mutable sequence of integers?
A) tuple
B) int
C) list
D) set
Answer: C

Q64. What is the output of type(42.0)?


A) <class 'int'>
B) <class 'float'>
C) <class 'complex'>
D) <class 'decimal'>
Answer: B

Q65. Which of the following is immutable?


A) list
B) dict
C) set
D) frozenset
Answer: D

Q66. Which built-in type represents a fixed sequence that can’t be modified?
A) list
B) tuple
C) dict
D) set
Answer: B

Q67. Which is NOT a valid way to denote a string literal in Python?


A) 'Hello'
B) "World"
C) Hello
D) '''Hello'''
Answer: C

Q68. What does the literal 0b1010 represent?


A) A floating point number
B) A complex number
C) A binary number
D) A string
Answer: C

Q69. Which of the following values converts to False when using bool()?
A) A non-empty string
B) A nonzero integer
C) An empty list
D) None of the above
Answer: C

Q70. Which data type is used for textual data?


A) int
B) float
C) str
D) bool
Answer: C

Q71. Which numeric type can represent very large numbers without overflow?
A) int
B) float
C) complex
D) short
Answer: A

Q72. What does the function len() return when called on a string?
A) The first character
B) The length of the string
C) The string reversed
D) An error if empty
Answer: B

Q73. Which of the following is NOT a method available on Python strings?


A) upper()
B) lower()
C) append()
D) split()
Answer: C

Q74. Which type is ideal for storing a collection of unique items?


A) list
B) tuple
C) set
D) dict
Answer: C
Q75. What is the data type of the literals True and False?
A) str
B) int
C) bool
D) float
Answer: C

Q76. What is the result of converting an empty tuple to a list?


A) An error
B) An empty list
C) A list with one element
D) None
Answer: B

Q77. Which method adds an item to the end of a list?


A) add()
B) append()
C) insert()
D) extend()
Answer: B

Q78. Which function converts a value to a string?


A) str()
B) int()
C) list()
D) dict()
Answer: A
Q79. Which of the following is a correct way to define a complex number?
A) complex(1, 2)
B) 1+2
C) '1+2j'
D) [1, 2j]
Answer: A

Q80. Which data type is unordered and does not support indexing?
A) list
B) tuple
C) set
D) str
Answer: C

Q81. Which keyword is used to represent the absence of a value?


A) null
B) None
C) nil
D) undef
Answer: B

Q82. What is the type of the result of bool('False')?


A) bool
B) str
C) int
D) NoneType
Answer: A

Q83. Which of the following can be concatenated using the + operator?


A) list and tuple
B) string and string
C) int and int
D) bool and int
Answer: B

Q84. Which data type is used to store an ordered collection of items?


A) dict
B) list
C) set
D) frozenset
Answer: B

Q85. Which of the following operations is valid on Python strings?


A) 'Hello' + ' World'
B) 'Hello' - 'World'
C) 'Hello' * 'World'
D) 'Hello' / 'World'
Answer: A

Q86. What does type([1, 2, 3]) return?


A) <class 'list'>
B) <class 'tuple'>
C) <class 'set'>
D) <class 'dict'>
Answer: A

Q87. What data type is created when a value is enclosed in quotes?


A) int
B) float
C) str
D) list
Answer: C

Q88. Which built-in function checks if an object is an instance of a specific data type?
A) check()
B) isinstance()
C) typecheck()
D) istype()
Answer: B

Q89. What does the data type None represent?


A) A zero value
B) An undefined value
C) A null value indicating no value
D) A false boolean value
Answer: C

Q90. Which of the following correctly represents a list of integers?


A) [1, '2', 3]
B) [1, 2, 3]
C) (1, 2, 3)
D) {1, 2, 3}
Answer: B

Q91. Which data type is best for representing key-value pairs where order matters (Python 3.7+)?
A) dict
B) set
C) list
D) tuple
Answer: A

Q92. Which of the following is considered a mapping type?


A) list
B) tuple
C) dict
D) set
Answer: C

Q93. When would you choose a tuple over a list?


A) When you need an ordered, mutable sequence
B) When you require an immutable sequence
C) When you need to modify the elements
D) When you want to enforce duplicate values
Answer: B

Q94. Which operation works with both lists and tuples?


A) Appending an element
B) Slicing
C) In-place sorting
D) Removing an element by value
Answer: B

Q95. Which statement is correct about Python data types?


A) Strings are mutable.
B) Lists are immutable.
C) Dictionary keys must be hashable.
D) Sets allow duplicate elements.
Answer: C

Q96. What does type(None) return?


A) <class 'None'>
B) <class 'NoneType'>
C) <class 'null'>
D) <class 'undefined'>
Answer: B

Q97. Which data type is best for storing a sequence of characters?


A) bytes
B) str
C) list
D) int
Answer: B

Q98. How is a float literal denoted in Python?


A) 3
B) 3.0
C) '3'
D) 3j
Answer: B

Q99. What is the boolean value of an empty list?


A) True
B) False
C) 0
D) None
Answer: B

Q100. Which data type allows duplicate elements in Python?


A) set
B) frozenset
C) list
D) dict keys
Answer: C

You might also like