TUPLES Data Structure

Pubblicato il: 28 aprile 2025
sul canale di: Mastering Technology
59
9

Difference Between Lists and Tuples-    • Difference B/w LISTS & TUPLES #python #pro...  

LISTS Data Structure -    • LISTS Data Structures in Python/Python Lis...  

TUPLES
It is an ordered immutable collection of objects. It consists of heterogenous elements indexed with integers. Duplicate elements are also allowed. It is created by using common bracket parenthesis or by using built-in function named as tuple.

Discuss the Following in detail with Python code:

1. Create a tuple with heterogenous elements.
2. Create a tuple with Single element.
3. Comparison with the creation of single string inside python.
4. Create tuple using in-built function named tuple.
5. Create an empty tuple.
6. Concatenation of tuples using addition operator.
7. Duplicate the tuple a given number of times using multiplicative operator.
8. Count Function to calculate the duplicate elements inside the tuple.
9. Find length of the tuple using len function.
10. Find the sum, max and min element using homogenous elements inside tuple.
11. Sort the tuple either in ascending or descending order using sorted function.

#tuple
l=(1,3,5,'start','life',9,8)
print(l)

#Create a tuple with single element
g='yu',
print(g)
print(type(g))

#Single value in parenthesis is not a tuple
h=('o')
print(h)
print(type(h))


#Create tuple using in-built function tuple
t=tuple('lambda')
print(t)

#Create an empty tuple
d=tuple()
print(d)

#Concatenation of tuples
r=('l','e','n')
d=('g','t','h')
e= r+d
print(e)

#Duplicate the tuple a given number of times
u=tuple('queen')*3
print(u)

#Count function
w=(1,1,2,2,2,2,4,5,6,7)
s=w.count(2)
print(s)


#Length of tuple
f=len(l)
print(f)

#Sum,Min,Max
l2=(13,120,9)
print(sum(l2))
print(max(l2))
print(min(l2))


#Sorting in ascending order
k=sorted(l2)
print(k)

#Sorting in descending order
m=sorted(l2,reverse=True)
print(m)

#tuple #sequence #of #values #heterogeneous #elements #indexing #creation #using #single #element #tuple #built-in #function #common #parentheses #concatenation #of #tuples #duplicate #repeat #many #times #count #function #sorted #ascending #descending #order

#like #share #subscribe #mychannel

#follow #on #medium :   / aggarwalakshima  


In questa pagina del sito puoi guardare il video online TUPLES Data Structure della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Mastering Technology 28 aprile 2025, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 59 volte e gli è piaciuto 9 spettatori. Buona visione!