Tuple are used to store multiple values in a single variable.
- Ordered =
Tuples are an ordered sequences of items, just like lists.
- Unchangeable =
Tuples are unchangeable, meaning that we cannot change, add or remove items after the tuple has been created.
- Allow Duplicates =
tuples are indexed, they can have items with the same value.
MyBasket=('Apple','Banana','Grapes','Oranges')
ListMyBasket=list(MyBasket)
ListMyBasket[0]='Cherry'
MyBasket=tuple(ListMyBasket)
print(MyBasket)PythonStudent=('Neha','Gauri','Vaibhavi','Meghana')
print(PythonStudent.index("Neha"))The count() method returns the number of times the specified element appears in the list.
PythonStudent=('Neha','Gauri','Vaibhavi','Gauri','Meghana','Gauri')
print(PythonStudent.count("Gauri"))To concatenate, or combine, two strings you can use the + operator.
a = "Hello"
b = "World"
c = a + b
print(c)1️⃣Write a program to change value touple to using extra overhead work.
👁 Show Answer
Colour=('Red','Blue','pink','Orange','Yellow')
ListColour=list(Colour)
ListColour[0]='Green'
Colour=tuple(ListColour)
print(Colour) #change value of tuple2️⃣ Write a program to use function index,count and also perform concatenation of two tuple.
👁 Show Answer
#Index Function
Colour=('Red','Blue','pink','Orange','Yellow')
print(Colour.index("pink"))
#Count Function
Colour=('Red','Blue','pink','Orange','Yellow')
print(Colour.count("Yellow"))
#Concatenation of String
Name= "Mahatma"
Surname=" Gandhi"
Full_Name = Name + Surname
print(Full_Name) 🔗 Some Useful Links

