0% found this document useful (0 votes)
2 views1 page

Tuple Functions Methods Program

The document explains Python tuples, which are ordered and immutable collections of elements. It outlines various tuple functions such as len(), max(), min(), and sum(), as well as methods like count() and index(). A sample program demonstrates the use of these functions with a tuple.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views1 page

Tuple Functions Methods Program

The document explains Python tuples, which are ordered and immutable collections of elements. It outlines various tuple functions such as len(), max(), min(), and sum(), as well as methods like count() and index(). A sample program demonstrates the use of these functions with a tuple.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Python Tuple Functions and Methods (With Program)

Tuple in Python is an ordered and immutable collection of elements. It is written inside


parentheses (). Because tuples are immutable, their elements cannot be changed after
creation.

Tuple Functions
1. len() – Returns the number of elements in the tuple.

2. max() – Returns the largest element in the tuple.

3. min() – Returns the smallest element in the tuple.

4. sum() – Returns the sum of all elements in the tuple.

Tuple Methods
1. count(x) – Returns the number of times element x appears in the tuple.

2. index(x) – Returns the index of the first occurrence of element x in the tuple.

Program Using Tuple Functions

# Program to demonstrate tuple functions

# Creating a tuple
t = (15, 25, 10, 40, 30)

print("Tuple elements:", t)

# Using tuple functions


print("Length of tuple:", len(t))
print("Maximum value:", max(t))
print("Minimum value:", min(t))
print("Sum of elements:", sum(t))

You might also like