#----------------------------------------------------------------------------------------------------------
# CODE SNIPPEST
#----------------------------------------------------------------------------------------------------------
tup = ('1','2','3') #creating tupple with values
tup1 = () #creating an empty tupple
tup2 = (10,) #if tupple contains only one value, comma should be there after value
#slicing tupples
print tup2[0]
print tup[0:2]
details = ("Avinash", 24, "Netcore", "Thane") #packing tupple
(name,age,company,location) = details #unpacking tupple
print name
print age
print company
print location
print details
#compairing tupples
a=(5,6)
b=(1,4)
if (a>b):print "a is bigger"
else: print "b is bigger"
a=(5,6)
b=(5,4)
if (a>b):print "a is bigger"
else: print "b is bigger"
a=(5,6)
b=(6,4)
if (a>b):print "a is bigger"
else: print "b is bigger"
a = {'x':100, 'y':200}
b = a.items() #convert dictionary to list of tupple
print b
a1 = (1,4,7,3,2,44,24,0,34,24,90,14)
print len(a1)
print max(a1)
print min(a1)
print sorted(a1) #sorting tupple values
#------------------------------------------------------------------------------------------------------
# OUTPUT
#------------------------------------------------------------------------------------------------------
root@Avinash:~/python_codes# python tupple.py
10
('1', '2')
Avinash
24
Netcore
Thane
('Avinash', 24, 'Netcore', 'Thane')
a is bigger
a is bigger
b is bigger
[('y', 200), ('x', 100)]
12
90
0
[0, 1, 2, 3, 4, 7, 14, 24, 24, 34, 44, 90]
root@Avinash:~/python_codes#
# CODE SNIPPEST
#----------------------------------------------------------------------------------------------------------
tup = ('1','2','3') #creating tupple with values
tup1 = () #creating an empty tupple
tup2 = (10,) #if tupple contains only one value, comma should be there after value
#slicing tupples
print tup2[0]
print tup[0:2]
details = ("Avinash", 24, "Netcore", "Thane") #packing tupple
(name,age,company,location) = details #unpacking tupple
print name
print age
print company
print location
print details
#compairing tupples
a=(5,6)
b=(1,4)
if (a>b):print "a is bigger"
else: print "b is bigger"
a=(5,6)
b=(5,4)
if (a>b):print "a is bigger"
else: print "b is bigger"
a=(5,6)
b=(6,4)
if (a>b):print "a is bigger"
else: print "b is bigger"
a = {'x':100, 'y':200}
b = a.items() #convert dictionary to list of tupple
print b
a1 = (1,4,7,3,2,44,24,0,34,24,90,14)
print len(a1)
print max(a1)
print min(a1)
print sorted(a1) #sorting tupple values
#------------------------------------------------------------------------------------------------------
# OUTPUT
#------------------------------------------------------------------------------------------------------
root@Avinash:~/python_codes# python tupple.py
10
('1', '2')
Avinash
24
Netcore
Thane
('Avinash', 24, 'Netcore', 'Thane')
a is bigger
a is bigger
b is bigger
[('y', 200), ('x', 100)]
12
90
0
[0, 1, 2, 3, 4, 7, 14, 24, 24, 34, 44, 90]
root@Avinash:~/python_codes#