Which of the following statements is TRUE about mutable and immutable data types in Python? 

a)Mutable data types can be modified in place, while immutable data types create a new object when modified. 

b)Mutable data types are faster and more efficient than immutable data types. 

c)Mutable data types are always passed by reference, while immutable data types are always passed by value. 

d)Mutable data types have a fixed size and memory allocation, while immutable data types have a variable size and memory allocation.

Answer:

Answer by student

a)Mutable data types can be modified in place, while immutable data types create a new object when modified.

Detailed answer by teachoo

  • In Python, data types can be classified into two categories: mutable and immutable.
  • Mutable data types are those that can be changed after they are created, while immutable data types are those that cannot be changed after they are created.
  • Examples of mutable data types are lists, dictionaries and sets, while examples of immutable data types are strings, numbers and tuples.

Let’s look at the options and see why they are correct or incorrect:

The rest of the post is locked. Join Teachoo Black to see the full post.

Go Ad-free
Davneet Singh's photo - Co-founder, Teachoo

Made by

Davneet Singh

Davneet Singh has done his B.Tech from Indian Institute of Technology, Kanpur. He has been teaching from the past 14 years. He provides courses for Maths, Science, Social Science, Physics, Chemistry, Computer Science at Teachoo.