- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What does immutable mean? Which Python types are mutable and which are not?
In Python, there are two types of Objects.
- Mutable Object
- Immutable Object
Mutable: Mutable objects are modified, (i.e) objects are a changeable list, set, dict, etc are mutable.
mutable objects are easy to change.
Example 1
list =["Tutorials ","Point", "Pvt","Ltd"] list[2]= 'Tutorix' list
Output
['Tutorials ', 'Point', 'Tutorix', 'Ltd']
Example 2
list=['Car','Bike','Scooty','Bus','Metro'] list[4]= 'Bicycle' list
Output
['Car', 'Bike', 'Scooty', 'Bus', 'Bicycle']
Immutable: immutable objects are not modified (i.e) not changeable int, float, bool, str, tuple, Unicode, etc ... are immutable. immutable objects are expensive and difficult to change. a tuple is enclosed within the parenthesis tuples are immutable and can't be changed.
Example 1
tuple=('1','2','Python','Perl') tuple
Output
('1', '2', 'Python', 'Perl')
Example 2
tuple=('1','2','Python','Perl') tuple[4]='2019' tuple
Output
TypeError Traceback (most recent call last) in 1 tuple=('1','2','Python','Perl') ----> 2 tuple[4]='2019' 3 tuple TypeError: 'tuple' object does not support item assignment
tuple object cant be changed by seeing above output you get a clear understanding
- Related Articles
- Which data types are immutable in Python?
- Difference between mutable and immutable in python?
- Name mutable and immutable objects in Python
- Difference between mutable and immutable object
- What is the difference between a mutable and immutable string in C#?
- What are the different types of stylish bottoms for women which I may not know of?
- What are the factors on which the time period of a simple pendulum does not depend?
- What are the types of process scheduling algorithms and which algorithms lead to starvation?
- Python - Show which entries in a Pandas Index are not NA
- How can you avoid getting an error if you are deleting a table which does not exist using Python?
- Check which of the following are solutions of the equations $2x -y =6$ and which are not.$(3, 0)$
- Check which of the following are solutions of the equations $2x -y =6$ and which are not.$(0, 6)$
- Check which of the following are solutions of the equations $2x -y =6$ and which are not.$(2,-2)$
- Check which of the following are solutions of the equations $2x -y =6$ and which are not.$(sqrt3, 0)$
- What are compound data types and data structures in Python?

Advertisements