List vs Tuples in Python
Master Python with 70+ Hands-on Projects and Get Job-ready - Learn Python
Program 1
import sys
#Difference between List and Tuple
# mylist=[101,"Vivek",89.99,True,10+5j,"Vivek"] # Mutable
# mytuple=(101,"Vivek",89.99,True,10+5j,"Vivek") # Immutable
# print("Size of List: ",sys.getsizeof(mylist))
# print("Size of Tuple: ",sys.getsizeof(mytuple))
# print(type(mylist))
# print(type(mytuple))
# print(mylist)
# mylist[1]="Vivek From Indore"
# print(mylist)
# print(mytuple)
# mytuple[1]="Vivek From Indore"
# print(mytuple)
# print("Elements of List: ")
# for x in mylist:
# print(x)
# print("Elements of Tuple: ")
# for x in mytuple:
# print(x)
# print("Elements of List using index value: ")
# for i in range(0,len(mylist),1):
# print(mylist[i])
# print("Elements of Tuple using index value: ")
# for i in range(0,len(mytuple),1):
# print(mytuple[i])
# mylist=[10]
# print(type(mylist))
# mytuple=(10,)
# print(type(mytuple))
# mylist=[]
# n=int(input("Enter the limit"))
# print("Enter the element")
# for i in range(0,n,1):
# x=int(input())
# mylist.append(x)
# mytuple=(mylist)
# print(mytuple)
# n=int(input("Enter the limit"))
# print("Enter the element")
# for i in range(0,n,1):
# x=int(input())
# mytuple.append(x)
# print(mytuple)
Did you like our efforts? If Yes, please give DataFlair 5 Stars on Google

