(part 1)

#Removing a Tuple:

1

2

3

4

# Deleting a tuple

LetsUpgrade= ( 0, 1, 'Batch')

del LetsUpgrade

print(LetsUpgrade)

Output

--------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-23-4c5803d03736> in <module>
      2 LetsUpgrade = ( 0, 1, 'Batch')
      3 del LetsUpgrade
----> 4 print(LetsUpgrade)

NameError: name 'LetsUpgrade' is not defined

Oh! it’s an Error…

Don’t worry, because once you give the command ‘del tuple_name’, it will automatically delete the TUPLE and thus, it generates NameError as shown above.

#Concatenation of Tuples:

1

2

3

4

# Concatenating 2 tuples

Batch1 = (0, 1, 2, 3)

Batch2 = ('LetsUpgrade', 'Student')

print(Batch1 + Batch2 )

Output

(0, 1, 2, 3, 'LetsUpgrade', 'Student')

#Other Basic Operations in Tuple:

PYTHON EXPRESSIONRESULTSDESCRIPTION
(‘Batch’,) * 3(‘Batch’, ‘Batch’, ‘Batch’)Repetition
3 in (1, 2, 3)TrueMembership
for x in (1, 2, 3):
print (x)
1
2
3
Iteration

Try executing above codes to get the desired results as shown…

#No Enclosing Delimiters:

Now, what is delimiter? Well, go GOOGLE it…

1

2

3

4

#No Enclosing Delimiters

print ('abc', -4.24e93, 18+6.6j, 'xyz')

x, y = 1, 2

print ("Value of x , y : ", x,y)

Output

abc -4.24e+93 (18+6.6j) xyz
Value of x , y :  1 2

Any set of multiple objects, comma-separated, written without identifying symbols, i.e., brackets for lists, parentheses for tuples, etc., then it automatically default to tuples as shown in above example…

#Built-in Tuple Functions:

Now, your work is to GOOGLE the below functions and understand how they work in Python Programming. (Exercise)

SR.NO.FUNCTION WITH DESCRIPTION
1cmp(tuple1, tuple2) – Compares elements of both tuples.
2len(tuple) – Gives the total length of the tuple.
3max(tuple) – Returns item from the tuple with max value.
4min(tuple) – Returns item from the tuple with min value.
5tuple(seq) – Converts a list into tuple.

Below 3 are the complex topics and therefore, request you to go through each Article:

—————————————– THE END ————————————————–

-Yogesh Raghupati (Author)