You are on page 1of 1

Assignment on the Tuples

How to define >> tuple=(1,2,3,[4,5,6])


How to Retrive >> tuple[0]

>> It is defined by paranthasis i.e. round bracket


>> It may consist of list in the structure
>> It can have mixed DataType tuple = ('Prathmesh' 25, 4,52,5,8,'Kushwaha')
>> .count(Object) >> used to count no. of repeatation of given onbject
>> .index(Object) >> used to find the index of given object
>> It is immutable

Example :

tuple = ('Prathmesh','Kushwaha',25, 82.785, ['Shivadhar','Kushwaha',60], 'Hindu',


'Kushwaha')
print('Name of the Candidate : %s %s' %(tuple[0], tuple[1]))
print(f"Father's Name : %s %s" %(tuple[4][0], tuple[4][1]))
print('Age of the Candidate : {}'.format(tuple[2]))
print('Age of the Father : {}'.format(tuple[4][2]))
print('Religion : %s' %(tuple[5]))
print(f'Cast : {tuple[6]}')

Output :

Name of the Candidate : Prathmesh Kushwaha


Father's Name : Shivadhar Kushwaha
Age of the Candidate : 25
Age of the Father : 60
Religion : Hindu
Cast : Kushwaha

tuple.count('Kushwaha') >> 2
tuple.index('Hindu') >> 5
tuple.count('Prathmesh')>> 1
tuple.index(25) >> 2

You might also like