SlideShare a Scribd company logo
1 of 10
Tuples - built in Functions
Sivananthitha J
Tuples in Python: Built-In Functions
Tuples in Python are versatile data structures, and Python provides
several built-in functions to work with them effectively. In this
guide, we will explore these functions and learn how to use them.
len() - Getting the Length of a Tuple
● The `len()` function returns the number of elements in a tuple.
● It helps you determine the size of your tuple.
my_tuple = (1, 2, 3, 4, 5)
length = len(my_tuple) # length is now 5
max() and min() - Finding Maximum and
Minimum Values
● These functions help you find the maximum and minimum values within a
tuple containing comparable elements.
my_tuple = (5, 2, 8, 1, 9)
maximum = max(my_tuple) # maximum is 9
minimum = min(my_tuple) # minimum is 1
sum() - Summing the Elements
● The `sum()` function calculates the sum of all elements within a tuple of
numbers.
my_tuple = (1, 2, 3, 4, 5)
total = sum(my_tuple) # total is 15
sorted() - Sorting a Tuple
● The `sorted()` function returns a new sorted list from the elements of a
tuple.
my_tuple = (5, 2, 8, 1, 9)
sorted_tuple = tuple(sorted(my_tuple)) # sorted_tuple is (1, 2, 5, 8, 9)
any() and all() - Checking for Truthiness
● These functions help you evaluate the truthiness of elements within a
tuple.
● `any()` returns `True` if at least one element is `True`, while `all()`
returns `True` only if all elements are `True`.
my_tuple = (True, False, True)
result_any = any(my_tuple) # result_any is True
result_all = all(my_tuple) # result_all is False
tuple() - Converting Other Iterables to Tuples
● The `tuple()` constructor converts other iterable objects like lists and
strings into tuples.
my_list = [1, 2, 3]
my_tuple = tuple(my_list) # my_tuple is (1, 2, 3)
my_string = "hello"
char_tuple = tuple(my_string) # char_tuple is ('h', 'e', 'l', 'l', 'o')
Conclusion
● These builtin functions provide valuable tools for working with tuples in
Python, enabling you to perform common operations efficiently.
● Whether you need to find the length, sum elements, or sort the tuple,
Python's builtin functions have you covered.
Thank you.

More Related Content

Similar to Effective tuples in phyton template.pptx

Anton Kasyanov, Introduction to Python, Lecture4
Anton Kasyanov, Introduction to Python, Lecture4Anton Kasyanov, Introduction to Python, Lecture4
Anton Kasyanov, Introduction to Python, Lecture4
Anton Kasyanov
 

Similar to Effective tuples in phyton template.pptx (20)

computer science tuple in python project.pdf
computer science tuple in python project.pdfcomputer science tuple in python project.pdf
computer science tuple in python project.pdf
 
updated_tuple_in_python.pdf
updated_tuple_in_python.pdfupdated_tuple_in_python.pdf
updated_tuple_in_python.pdf
 
Tuple.py
Tuple.pyTuple.py
Tuple.py
 
Pytho_tuples
Pytho_tuplesPytho_tuples
Pytho_tuples
 
Python revision tour II
Python revision tour IIPython revision tour II
Python revision tour II
 
Chapter 17 Tuples
Chapter 17 TuplesChapter 17 Tuples
Chapter 17 Tuples
 
Chapter 13 Tuples.pptx
Chapter 13 Tuples.pptxChapter 13 Tuples.pptx
Chapter 13 Tuples.pptx
 
Chapter 13 Tuples.pptx
Chapter 13 Tuples.pptxChapter 13 Tuples.pptx
Chapter 13 Tuples.pptx
 
Lecture 09.pptx
Lecture 09.pptxLecture 09.pptx
Lecture 09.pptx
 
List,tuple,dictionary
List,tuple,dictionaryList,tuple,dictionary
List,tuple,dictionary
 
Python Variable Types, List, Tuple, Dictionary
Python Variable Types, List, Tuple, DictionaryPython Variable Types, List, Tuple, Dictionary
Python Variable Types, List, Tuple, Dictionary
 
PPT data science python sequence numpy.pptx
PPT data science python sequence numpy.pptxPPT data science python sequence numpy.pptx
PPT data science python sequence numpy.pptx
 
Tuples-and-Dictionaries.pptx
Tuples-and-Dictionaries.pptxTuples-and-Dictionaries.pptx
Tuples-and-Dictionaries.pptx
 
set.pptx
set.pptxset.pptx
set.pptx
 
Python Interview Questions And Answers
Python Interview Questions And AnswersPython Interview Questions And Answers
Python Interview Questions And Answers
 
Revision Tour 1 and 2 complete.doc
Revision Tour 1 and 2 complete.docRevision Tour 1 and 2 complete.doc
Revision Tour 1 and 2 complete.doc
 
Tuple Operation and Tuple Assignment in Python.pdf
Tuple Operation and Tuple Assignment in Python.pdfTuple Operation and Tuple Assignment in Python.pdf
Tuple Operation and Tuple Assignment in Python.pdf
 
Python programming -Tuple and Set Data type
Python programming -Tuple and Set Data typePython programming -Tuple and Set Data type
Python programming -Tuple and Set Data type
 
Python Lecture 11
Python Lecture 11Python Lecture 11
Python Lecture 11
 
Anton Kasyanov, Introduction to Python, Lecture4
Anton Kasyanov, Introduction to Python, Lecture4Anton Kasyanov, Introduction to Python, Lecture4
Anton Kasyanov, Introduction to Python, Lecture4
 

Recently uploaded

K Venkat Naveen Kumar | GCP Data Engineer | CV
K Venkat Naveen Kumar | GCP Data Engineer | CVK Venkat Naveen Kumar | GCP Data Engineer | CV
K Venkat Naveen Kumar | GCP Data Engineer | CV
K VENKAT NAVEEN KUMAR
 
Top profile Call Girls In Varanasi [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Varanasi [ 7014168258 ] Call Me For Genuine Models ...Top profile Call Girls In Varanasi [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Varanasi [ 7014168258 ] Call Me For Genuine Models ...
gajnagarg
 
Top profile Call Girls In Anantapur [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In Anantapur [ 7014168258 ] Call Me For Genuine Models...Top profile Call Girls In Anantapur [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In Anantapur [ 7014168258 ] Call Me For Genuine Models...
gajnagarg
 
Howrah [ Call Girls Kolkata ₹7.5k Pick Up & Drop With Cash Payment 8005736733...
Howrah [ Call Girls Kolkata ₹7.5k Pick Up & Drop With Cash Payment 8005736733...Howrah [ Call Girls Kolkata ₹7.5k Pick Up & Drop With Cash Payment 8005736733...
Howrah [ Call Girls Kolkata ₹7.5k Pick Up & Drop With Cash Payment 8005736733...
HyderabadDolls
 
Girls in Aiims Metro (delhi) call me [🔝9953056974🔝] escort service 24X7
Girls in Aiims Metro (delhi) call me [🔝9953056974🔝] escort service 24X7Girls in Aiims Metro (delhi) call me [🔝9953056974🔝] escort service 24X7
Girls in Aiims Metro (delhi) call me [🔝9953056974🔝] escort service 24X7
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Jual obat aborsi Jakarta ( 085657271886 )Cytote pil telat bulan penggugur kan...
Jual obat aborsi Jakarta ( 085657271886 )Cytote pil telat bulan penggugur kan...Jual obat aborsi Jakarta ( 085657271886 )Cytote pil telat bulan penggugur kan...
Jual obat aborsi Jakarta ( 085657271886 )Cytote pil telat bulan penggugur kan...
ZurliaSoop
 
<DUBAI>Abortion pills IN UAE {{+971561686603*^Mifepristone & Misoprostol in D...
<DUBAI>Abortion pills IN UAE {{+971561686603*^Mifepristone & Misoprostol in D...<DUBAI>Abortion pills IN UAE {{+971561686603*^Mifepristone & Misoprostol in D...
<DUBAI>Abortion pills IN UAE {{+971561686603*^Mifepristone & Misoprostol in D...
gynedubai
 
Top profile Call Girls In Hubli [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Hubli [ 7014168258 ] Call Me For Genuine Models We ...Top profile Call Girls In Hubli [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Hubli [ 7014168258 ] Call Me For Genuine Models We ...
gajnagarg
 
Top profile Call Girls In Sagar [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Sagar [ 7014168258 ] Call Me For Genuine Models We ...Top profile Call Girls In Sagar [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Sagar [ 7014168258 ] Call Me For Genuine Models We ...
nirzagarg
 
Jual obat aborsi Dubai ( 085657271886 ) Cytote pil telat bulan penggugur kand...
Jual obat aborsi Dubai ( 085657271886 ) Cytote pil telat bulan penggugur kand...Jual obat aborsi Dubai ( 085657271886 ) Cytote pil telat bulan penggugur kand...
Jual obat aborsi Dubai ( 085657271886 ) Cytote pil telat bulan penggugur kand...
ZurliaSoop
 

Recently uploaded (20)

K Venkat Naveen Kumar | GCP Data Engineer | CV
K Venkat Naveen Kumar | GCP Data Engineer | CVK Venkat Naveen Kumar | GCP Data Engineer | CV
K Venkat Naveen Kumar | GCP Data Engineer | CV
 
Kannada Call Girls Mira Bhayandar WhatsApp +91-9930687706, Best Service
Kannada Call Girls Mira Bhayandar WhatsApp +91-9930687706, Best ServiceKannada Call Girls Mira Bhayandar WhatsApp +91-9930687706, Best Service
Kannada Call Girls Mira Bhayandar WhatsApp +91-9930687706, Best Service
 
Vip Malegaon Escorts Service Girl ^ 9332606886, WhatsApp Anytime Malegaon
Vip Malegaon Escorts Service Girl ^ 9332606886, WhatsApp Anytime MalegaonVip Malegaon Escorts Service Girl ^ 9332606886, WhatsApp Anytime Malegaon
Vip Malegaon Escorts Service Girl ^ 9332606886, WhatsApp Anytime Malegaon
 
UIowa Application Instructions - 2024 Update
UIowa Application Instructions - 2024 UpdateUIowa Application Instructions - 2024 Update
UIowa Application Instructions - 2024 Update
 
Top profile Call Girls In Varanasi [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Varanasi [ 7014168258 ] Call Me For Genuine Models ...Top profile Call Girls In Varanasi [ 7014168258 ] Call Me For Genuine Models ...
Top profile Call Girls In Varanasi [ 7014168258 ] Call Me For Genuine Models ...
 
Top profile Call Girls In Anantapur [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In Anantapur [ 7014168258 ] Call Me For Genuine Models...Top profile Call Girls In Anantapur [ 7014168258 ] Call Me For Genuine Models...
Top profile Call Girls In Anantapur [ 7014168258 ] Call Me For Genuine Models...
 
DMER-AYUSH-MIMS-Staff-Nurse-_Selection-List-04-05-2024.pdf
DMER-AYUSH-MIMS-Staff-Nurse-_Selection-List-04-05-2024.pdfDMER-AYUSH-MIMS-Staff-Nurse-_Selection-List-04-05-2024.pdf
DMER-AYUSH-MIMS-Staff-Nurse-_Selection-List-04-05-2024.pdf
 
Howrah [ Call Girls Kolkata ₹7.5k Pick Up & Drop With Cash Payment 8005736733...
Howrah [ Call Girls Kolkata ₹7.5k Pick Up & Drop With Cash Payment 8005736733...Howrah [ Call Girls Kolkata ₹7.5k Pick Up & Drop With Cash Payment 8005736733...
Howrah [ Call Girls Kolkata ₹7.5k Pick Up & Drop With Cash Payment 8005736733...
 
Ganga Path Project (marine drive project) Patna ,Bihar .pdf
Ganga Path Project (marine drive project) Patna ,Bihar .pdfGanga Path Project (marine drive project) Patna ,Bihar .pdf
Ganga Path Project (marine drive project) Patna ,Bihar .pdf
 
Girls in Aiims Metro (delhi) call me [🔝9953056974🔝] escort service 24X7
Girls in Aiims Metro (delhi) call me [🔝9953056974🔝] escort service 24X7Girls in Aiims Metro (delhi) call me [🔝9953056974🔝] escort service 24X7
Girls in Aiims Metro (delhi) call me [🔝9953056974🔝] escort service 24X7
 
Novo Nordisk Kalundborg. We are expanding our manufacturing hub in Kalundborg...
Novo Nordisk Kalundborg. We are expanding our manufacturing hub in Kalundborg...Novo Nordisk Kalundborg. We are expanding our manufacturing hub in Kalundborg...
Novo Nordisk Kalundborg. We are expanding our manufacturing hub in Kalundborg...
 
Athwa gate \ Call Girls Service Ahmedabad - 450+ Call Girl Cash Payment 80057...
Athwa gate \ Call Girls Service Ahmedabad - 450+ Call Girl Cash Payment 80057...Athwa gate \ Call Girls Service Ahmedabad - 450+ Call Girl Cash Payment 80057...
Athwa gate \ Call Girls Service Ahmedabad - 450+ Call Girl Cash Payment 80057...
 
Jual obat aborsi Jakarta ( 085657271886 )Cytote pil telat bulan penggugur kan...
Jual obat aborsi Jakarta ( 085657271886 )Cytote pil telat bulan penggugur kan...Jual obat aborsi Jakarta ( 085657271886 )Cytote pil telat bulan penggugur kan...
Jual obat aborsi Jakarta ( 085657271886 )Cytote pil telat bulan penggugur kan...
 
<DUBAI>Abortion pills IN UAE {{+971561686603*^Mifepristone & Misoprostol in D...
<DUBAI>Abortion pills IN UAE {{+971561686603*^Mifepristone & Misoprostol in D...<DUBAI>Abortion pills IN UAE {{+971561686603*^Mifepristone & Misoprostol in D...
<DUBAI>Abortion pills IN UAE {{+971561686603*^Mifepristone & Misoprostol in D...
 
Top profile Call Girls In Hubli [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Hubli [ 7014168258 ] Call Me For Genuine Models We ...Top profile Call Girls In Hubli [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Hubli [ 7014168258 ] Call Me For Genuine Models We ...
 
drug book file on obs. and gynae clinical pstings
drug book file on obs. and gynae clinical pstingsdrug book file on obs. and gynae clinical pstings
drug book file on obs. and gynae clinical pstings
 
9352852248 Call Girls Sanand Escort Service Available 24×7 In Sanand
9352852248 Call Girls  Sanand Escort Service Available 24×7 In Sanand9352852248 Call Girls  Sanand Escort Service Available 24×7 In Sanand
9352852248 Call Girls Sanand Escort Service Available 24×7 In Sanand
 
Top profile Call Girls In Sagar [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Sagar [ 7014168258 ] Call Me For Genuine Models We ...Top profile Call Girls In Sagar [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Sagar [ 7014168258 ] Call Me For Genuine Models We ...
 
Call Girls In GOA North Goa +91-8588052666 Direct Cash Escorts Service
Call Girls In GOA North Goa +91-8588052666 Direct Cash Escorts ServiceCall Girls In GOA North Goa +91-8588052666 Direct Cash Escorts Service
Call Girls In GOA North Goa +91-8588052666 Direct Cash Escorts Service
 
Jual obat aborsi Dubai ( 085657271886 ) Cytote pil telat bulan penggugur kand...
Jual obat aborsi Dubai ( 085657271886 ) Cytote pil telat bulan penggugur kand...Jual obat aborsi Dubai ( 085657271886 ) Cytote pil telat bulan penggugur kand...
Jual obat aborsi Dubai ( 085657271886 ) Cytote pil telat bulan penggugur kand...
 

Effective tuples in phyton template.pptx

  • 1. Tuples - built in Functions Sivananthitha J
  • 2. Tuples in Python: Built-In Functions Tuples in Python are versatile data structures, and Python provides several built-in functions to work with them effectively. In this guide, we will explore these functions and learn how to use them.
  • 3. len() - Getting the Length of a Tuple ● The `len()` function returns the number of elements in a tuple. ● It helps you determine the size of your tuple. my_tuple = (1, 2, 3, 4, 5) length = len(my_tuple) # length is now 5
  • 4. max() and min() - Finding Maximum and Minimum Values ● These functions help you find the maximum and minimum values within a tuple containing comparable elements. my_tuple = (5, 2, 8, 1, 9) maximum = max(my_tuple) # maximum is 9 minimum = min(my_tuple) # minimum is 1
  • 5. sum() - Summing the Elements ● The `sum()` function calculates the sum of all elements within a tuple of numbers. my_tuple = (1, 2, 3, 4, 5) total = sum(my_tuple) # total is 15
  • 6. sorted() - Sorting a Tuple ● The `sorted()` function returns a new sorted list from the elements of a tuple. my_tuple = (5, 2, 8, 1, 9) sorted_tuple = tuple(sorted(my_tuple)) # sorted_tuple is (1, 2, 5, 8, 9)
  • 7. any() and all() - Checking for Truthiness ● These functions help you evaluate the truthiness of elements within a tuple. ● `any()` returns `True` if at least one element is `True`, while `all()` returns `True` only if all elements are `True`. my_tuple = (True, False, True) result_any = any(my_tuple) # result_any is True result_all = all(my_tuple) # result_all is False
  • 8. tuple() - Converting Other Iterables to Tuples ● The `tuple()` constructor converts other iterable objects like lists and strings into tuples. my_list = [1, 2, 3] my_tuple = tuple(my_list) # my_tuple is (1, 2, 3) my_string = "hello" char_tuple = tuple(my_string) # char_tuple is ('h', 'e', 'l', 'l', 'o')
  • 9. Conclusion ● These builtin functions provide valuable tools for working with tuples in Python, enabling you to perform common operations efficiently. ● Whether you need to find the length, sum elements, or sort the tuple, Python's builtin functions have you covered.

Editor's Notes

  1. Entered text Certainly, here's an end-to-end explanation of Python's built-in tuple functions: --- **Tuples in Python: Built-In Functions** Tuples in Python are versatile data structures, and Python provides several built-in functions to work with them effectively. In this guide, we will explore these functions and learn how to use them. **1. len() - Getting the Length of a Tuple** The `len()` function returns the number of elements in a tuple. It helps you determine the size of your tuple. ```python my_tuple = (1, 2, 3, 4, 5) length = len(my_tuple) # length is now 5 ``` **2. max() and min() - Finding Maximum and Minimum Values** These functions help you find the maximum and minimum values within a tuple containing comparable elements. ```python my_tuple = (5, 2, 8, 1, 9) maximum = max(my_tuple) # maximum is 9 minimum = min(my_tuple) # minimum is 1 ``` **3. sum() - Summing the Elements** The `sum()` function calculates the sum of all elements within a tuple of numbers. ```python my_tuple = (1, 2, 3, 4, 5) total = sum(my_tuple) # total is 15 ``` **4. sorted() - Sorting a Tuple** The `sorted()` function returns a new sorted list from the elements of a tuple. ```python my_tuple = (5, 2, 8, 1, 9) sorted_tuple = tuple(sorted(my_tuple)) # sorted_tuple is (1, 2, 5, 8, 9) ``` **5. any() and all() - Checking for Truthiness** These functions help you evaluate the truthiness of elements within a tuple. `any()` returns `True` if at least one element is `True`, while `all()` returns `True` only if all elements are `True`. ```python my_tuple = (True, False, True) result_any = any(my_tuple) # result_any is True result_all = all(my_tuple) # result_all is False ``` **6. tuple() - Converting Other Iterables to Tuples** The `tuple()` constructor converts other iterable objects like lists and strings into tuples. ```python my_list = [1, 2, 3] my_tuple = tuple(my_list) # my_tuple is (1, 2, 3) my_string = "hello" char_tuple = tuple(my_string) # char_tuple is ('h', 'e', 'l', 'l', 'o') ``` These built-in functions provide valuable tools for working with tuples in Python, enabling you to perform common operations efficiently. Whether you need to find the length, sum elements, or sort the tuple, Python's built-in functions have you covered.