List / Tuples and Key Features Of Python

What is the difference between list and tuples in Python?

Difference Between List And Tuples In Python
Difference Between List And Tuples In Python
ListTuple
1) List are mutable that means we can do changes in list
Example:
lis=[1,2,3]
lis.append(4)
print(lis)
output:- [1, 2, 3, 4]
Tuple are immutable that’s means we cannot do changes in tuple after the tuple declaration
Example:
t=(1, 2, 3, 4)
t.append(5)
Output:- AttributeError: ‘tuple’ object has no attribute ‘append’
from above example we can understand we cannot do changes in tuple
List has data stored in []
Example:
Lis=[‘a’,’b’,’c’]
tuple has data stored in ()
Example
t=(‘a’,’b’,’c’)
List is a collection of data like array
in list we can perform deletion and insertion operation
Tuple is a collection data in tuple we cannot perform insert data and delete operation tuple is static use for accessing element
List are slower than Tuples
List required two memory block to accessed that’s why it is slower than tuple
Tuple is faster than list
operations performed on list:
1)Add element
Lis=[1,2,3,]
Lis.append(4)
print(Lis)
Output-[1,2,3,4]
Operations on tuple:
1) Accessing the element from tuple
t=(1, 2, 3, 4)
print(t[1])
output:- 2
2) Delete element:
Lis.pop()
print(lis)
Output:- [1,2,3]
3) Accessing the element
print(Lis[1])
output- 2
Difference between List vs Tumple

What are the key features of Python?

The Key Features Of Python
The Key Features Of Python
  1. python is high level programming language and easy to code and interpreted language
    In python not need to write library in c and cpp we need initialized input output library but in python not need we can directly do this task no need to semicolon end of the statement python not need to { } for statement python work on indentation
    2) python support object oriented programming :
    like cpp and java python is support class and object paradigms
    we perform oops concept in python like Abstraction, encapsulation, Inheritance, polymorphism
    3) python is portable and integrated language
    portable means if we have python code for windows and we want to run same program in Linux or mac then no need to changes in code
    and integrated means we can integrate python with other language like c,java cpp
    4) python have large collection of library :
    python if very famous programming language because of simple and large collection
    of library
    example of library :
    numpy, pandas, matplotlib, Keras , Scipy, Turtule, Pillow, openCV etc
    5) with the help of python machine learning and AI is simple
    6) python have Graphical User Interface support for developing
    7) python have large collection of library and that’s why python is very powerful language we can do many work in python easily
    8) python have many built-in function for fast and easy to code

Example
• print()- print() is used for print the data
• input() – is used for take input from user
• len() – is used for calculate the length
• abs()-return the absolute numeric value
• sum()- is used to do addition of element present in the array or list
• min()/max()- is used to fiend minimum and maximum
• sort()- Is use to sort the array
etc… python have built-in method

Summary :

In this article we saw What Is The Difference Between List And Tuples In Python? and What Are The Key Features Of Python? so if about this article you have any query then free to ask me

Name of intern who share this Task: Pankaj Koche
https://github.com/pankajkoche

I am the founder of Pythonslearning, a Passionate Educational Blogger and Author, who love to share the informative content on educational resources.

Leave a Comment