MCQs on Python Core Data Types
Python Core Data Types: MCQs to Strengthen Your Understanding
Test your knowledge of Python Core Data Types with this engaging multiple-choice quiz. Sharpen your skills and strengthen your understanding of lists, tuples, sets, dictionaries, and more. Challenge yourself with questions covering the basics and the nuances of Python data types. Whether you're a beginner or an experienced Pythonista, this quiz is sure to put your knowledge to the test!
1. What are the four built-in data types in Python?
a) Integer
b) Float
c) String
d) Complex
View Answer
Answer: a, b, c, d
Python has four built-in data types: Integer, Float, String, and Complex.
2. What is the output of the expression 'hello' + 'world'?
a) hello world
b) helloworld
c) worldhello
d) error
View Answer
Answer: b
The output of the expression 'hello' + 'world' is 'helloworld'.
3. What is the difference between a list and a tuple?
a) A list is mutable, while a tuple is immutable
b) A tuple is mutable, while a list is immutable
c) Both list and tuple are mutable
d) Both list and tuple are immutable
View Answer
Answer: a
A list is mutable, while a tuple is immutable.
4. Which data type is used to represent a group of individual elements?
a) Tuple
b) List
c) Set
d) Dictionary
View Answer
Answer: b
A list is used to represent a group of individual elements.
5. What is the result of the expression 10 % 3?
a) 1
b) 2
c) 3
d) 4
View Answer
Answer: b
The result of the expression 10 % 3 is 1.
6. Which data type is used to represent a collection of unordered, unique elements?
a) List
b) Tuple
c) Set
d) Dictionary
View Answer
Answer: c
A set is used to represent a collection of unordered, unique elements.
7. What is the data type of the result of 5 / 2?
a) Integer
b) Float
c) Complex
d) String
View Answer
Answer: b
The data type of the result of 5 / 2 is float.
8. Which data type is used to represent a key-value pair?
a) List
b) Tuple
c) Set
d) Dictionary
View Answer
Answer: d
A dictionary is used to represent a key-value pair.
9. Which data type is used to represent a sequence of characters?
a) Integer
b) Float
c) String
d) Complex
View Answer
Answer: c
A string is used to represent a sequence of characters.
10. What is the difference between a float and an integer?
a) A float can represent decimal numbers, while an integer cannot
b) An integer can represent decimal numbers, while a float cannot
c) Both float and integer can represent decimal numbers
d) Both float and integer can only represent whole numbers
View Answer
Answer: a
A float can represent decimal numbers, while an integer cannot.
11. Which data type is mutable?
a) List
b) Tuple
c) Set
d) String
View Answer
Answer: a
A list is a mutable data type, meaning it can be modified after it is created.
12. What is the maximum value that can be represented by an integer data type in Python?
a) 2^32 - 1
b) 2^63 - 1
c) 2^128 - 1
d) There is no maximum value
View Answer
Answer: b
In Python, the maximum value that can be represented by an integer data type is 2^63 - 1.
13. Which data type is used to represent a group of ordered, immutable elements?
a) List
b) Tuple
c) Set
d) Dictionary
View Answer
Answer: b
A tuple is used to represent a group of ordered, immutable elements.
14. Which data type is used to represent a collection of elements that are not ordered and can contain duplicates?
a) List
b) Tuple
c) Set
d) Dictionary
View Answer
Answer: a
A list is used to represent a collection of elements that are not ordered and can contain duplicates.
15. What is the difference between a set and a frozenset?
a) A set is mutable while a frozenset is immutable
b) A set can contain duplicates while a frozenset cannot
c) A set is unordered while a frozenset is ordered
d) There is no difference between a set and a frozenset
View Answer
Answer: a
A set is mutable while a frozenset is immutable, meaning that a frozenset cannot be modified after it is created.