Tuples are used to store multiple items in a single variable.
Tuple is one of 4 built-in data types in Python used to store collections of data, the other 3 are List, Set, and Dictionary, all with different qualities and usage.
A tuple is a collection which is ordered and unchangeable.
Tuples are written with round brackets ()
T = ()
print(T)
T = (10,3.14,"Machine Learning",98.34,100,"Python",77)
print(T)
T[0]
print(len(T))
print(type(T))
T = (10,3.14,"Machine Learning",98.34,100,"Python",77)
print(T)
print(T[:])
print(T[::])
print(T[0])
print(T[2:5])
print(T[2:])
print(T[:5])
print(T[-1])
print(T[-3:])
print(T)
L = list(T)
L[1] = "Itronix Solutions"
T = tuple(L)
print(T)
a,b,c = ('python',10,45.66)
print(a)
print(b)
print(c)
T = (10,3.14,"Machine Learning",98.34,100,"Python",77)
for item in T:
print(item)
for i in range(len(T)):
print(L[i])
for i in range(len(T)):
print(L[i])
T = (10,3.14,"Machine Learning",98.34,100,"Python",77)
i=0
while i < len(T):
print(T[i])
i = i + 1
T1 = (1,2,3)
T2 = (4,5,6)
T3 = T1 + T2
print(T3)
T1 = (1,2,3)
print(T1 * 3)
T1 = (1,45,35,78,35,67,45,25,78,45)
T1.count(45)
T1.index(35)