MCQ on Python Data Types

Diving into the world of Python programming is an exciting journey, and understanding the basic data types is a important step. Python offers a diverse range of built-in data types, from simple integers and floats to complex lists and dictionaries. 

In this page, we’ve prepared a set of 15 Multiple Choice Questions (MCQs) specifically designed for beginners to evaluate their understanding of Python’s data types. Accompanying each question is a detailed explanation to enhance your learning experience. Let’s get started!

1. What is the data type of: 5?

a) Float
b) String
c) Integer
d) Complex

Answer:

c) Integer

Explanation:

The value 5 without a decimal point is an integer.

2. Which of the following is a mutable data type?

a) Tuple
b) String
c) List
d) Int

Answer:

c) List

Explanation:

Lists in Python can be altered after their creation, hence they are mutable. Other options are immutable.

3. Which data type is ordered and changeable, and allows duplicate members?

a) Set
b) Tuple
c) Dictionary
d) List

Answer:

d) List

Explanation:

A list is ordered, can be altered, and can have duplicate members.

4. What does the following code produce: type(5.0)?

a) int
b) float
c) str
d) complex

Answer:

b) float

Explanation:

5.0 is a floating-point number, so the type function will return float.

5. Which of the following can’t be a dictionary key?

a) Integer
b) Tuple
c) List
d) String

Answer:

c) List

Explanation:

Dictionary keys must be immutable, and since lists are mutable, they can’t be used as dictionary keys.

6. Which data type is unordered and unindexed?

a) Set
b) List
c) Tuple
d) Dictionary

Answer:

a) Set

Explanation:

Sets in Python are both unordered and unindexed.

7. Which of these is used to represent a sequences of characters?

a) List
b) Tuple
c) String
d) Set

Answer:

c) String

Explanation:

Strings are sequences of characters in Python.

8. Which data type cannot contain duplicate values?

a) List
b) Tuple
c) Set
d) Dictionary

Answer:

c) Set

Explanation:

Sets are unindexed collections of unique elements. They don’t allow duplicates.

9. What is the output of type((1,2))?

a) List
b) Set
c) Tuple
d) Dictionary

Answer:

c) Tuple

Explanation:

The values 1 and 2 enclosed in parentheses form a tuple.

10. Which of the following data types does not allow slicing?

a) String
b) List
c) Set
d) Tuple

Answer:

c) Set

Explanation:

Sets are unordered and unindexed, so slicing operations are not supported.

11. Which data type is immutable?

a) List
b) Dictionary
c) String
d) Set

Answer:

c) String

Explanation:

Strings in Python are immutable, meaning their values can’t be altered after they’re created.

12. How can you represent complex numbers in Python?

a) a+b
b) a_b
c) a+bj
d) a.b

Answer:

c) a+bj

Explanation:

In Python, complex numbers are represented as a+bj, where a and b are floats.

13. Which of the following is not a Python data type?

a) List
b) Class
c) Tuple
d) Dictionary

Answer:

b) Class

Explanation:

While classes are used to define new types in Python, they themselves aren’t a data type.

14. Which data type is mutable but ordered?

a) Tuple
b) Set
c) List
d) String

Answer:

c) List

Explanation:

Lists are ordered collections of elements and they can be modified after their creation.

15. Which data type can be used to represent a pair of values?

a) List
b) Tuple
c) Set
d) Dictionary

Answer:

b) Tuple

Explanation:

Tuples can hold an ordered collection of items, which can be of any type


Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top