SlideShare a Scribd company logo
1 of 7
1
ACCESSING THE TUPLES
Presented by,
R.Annalakshmi,
20PA03,
1-MCA,
Python programming
Accessing the tuples 11-04-2021
 A tuple is a collection of objects which ordered and
immutable.
 Tuples are sequences, just like lists. The differences
between tuples and lists are, the tuples cannot be
changed unlike lists and tuples use parentheses,
whereas lists use square brackets.
 tup1 = ('physics', 'chemistry', 1997, 2000);
 tup2 = (1, 2, 3, 4, 5 );
 tup3 = ("a", "b", "c", "d“);
2
Accessing the tuples 11-04-2021
 To access values in tuple, use the square brackets for
slicing along with the index or indices to obtain value
available at that index.
For example
 tup1 = ('physics', 'chemistry', 1997, 2000);
 tup2 = (1, 2, 3, 4, 5, 6, 7 );
 print "tup1[0]: ", tup1[0];
 print "tup2[1:5]: ", tup2[1:5];
 Output:
 tup1[0]: physics
 tup2[1:5]: [2, 3, 4, 5]
3
Accessing the tuples 11-04-2021
 Tuples are immutable which means you cannot update or
change the values of tuple elements. You are able to take
portions of existing tuples to create new tuples as,
 Example:
 tup1 = (12, 34.56);
 tup2 = ('abc', 'xyz');
 tup3 = tup1 + tup2;
 print tup3;
 Output:
 (12, 34.56, 'abc', 'xyz')
11-04-2021 4
Accessing the tuples
5
Accessing the tuples 11-04-2021
 Because tuples are sequences, indexing and slicing
work the same way for tuples as they do for strings.
 L = ('spam', 'Spam', 'SPAM!')
11-04-2021 6
Accessing the tuples
7
Accessing the tuples 11-04-2021

More Related Content

What's hot

Bayesian case studies, practical 1
Bayesian case studies, practical 1Bayesian case studies, practical 1
Bayesian case studies, practical 1Robin Ryder
 
Φύλλο Εργασίας 2 | Η έννοια της διάστασης
Φύλλο Εργασίας 2 | Η έννοια της διάστασηςΦύλλο Εργασίας 2 | Η έννοια της διάστασης
Φύλλο Εργασίας 2 | Η έννοια της διάστασηςΘΑΛΗΣ + ΦΙΛΟΙ
 
Binary Heap Tree, Data Structure
Binary Heap Tree, Data Structure Binary Heap Tree, Data Structure
Binary Heap Tree, Data Structure Anand Ingle
 

What's hot (7)

Heap sort
Heap sortHeap sort
Heap sort
 
Heap tree
Heap treeHeap tree
Heap tree
 
Bayesian case studies, practical 1
Bayesian case studies, practical 1Bayesian case studies, practical 1
Bayesian case studies, practical 1
 
euler theorm
euler theormeuler theorm
euler theorm
 
Φύλλο Εργασίας 2 | Η έννοια της διάστασης
Φύλλο Εργασίας 2 | Η έννοια της διάστασηςΦύλλο Εργασίας 2 | Η έννοια της διάστασης
Φύλλο Εργασίας 2 | Η έννοια της διάστασης
 
Functions
Functions Functions
Functions
 
Binary Heap Tree, Data Structure
Binary Heap Tree, Data Structure Binary Heap Tree, Data Structure
Binary Heap Tree, Data Structure
 

Similar to Accessing the tuples

Redundancy in robot manipulators and multi robot systems
Redundancy in robot manipulators and multi robot systemsRedundancy in robot manipulators and multi robot systems
Redundancy in robot manipulators and multi robot systemsSpringer
 
Approximate Bayesian Computation with Quasi-Likelihoods
Approximate Bayesian Computation with Quasi-LikelihoodsApproximate Bayesian Computation with Quasi-Likelihoods
Approximate Bayesian Computation with Quasi-LikelihoodsStefano Cabras
 
An Overview of Separation Axioms by Nearly Open Sets in Topology.
An Overview of Separation Axioms by Nearly Open Sets in Topology.An Overview of Separation Axioms by Nearly Open Sets in Topology.
An Overview of Separation Axioms by Nearly Open Sets in Topology.IJERA Editor
 
International Refereed Journal of Engineering and Science (IRJES)
International Refereed Journal of Engineering and Science (IRJES)International Refereed Journal of Engineering and Science (IRJES)
International Refereed Journal of Engineering and Science (IRJES)irjes
 

Similar to Accessing the tuples (6)

Tuples-and-Dictionaries.pptx
Tuples-and-Dictionaries.pptxTuples-and-Dictionaries.pptx
Tuples-and-Dictionaries.pptx
 
Redundancy in robot manipulators and multi robot systems
Redundancy in robot manipulators and multi robot systemsRedundancy in robot manipulators and multi robot systems
Redundancy in robot manipulators and multi robot systems
 
Approximate Bayesian Computation with Quasi-Likelihoods
Approximate Bayesian Computation with Quasi-LikelihoodsApproximate Bayesian Computation with Quasi-Likelihoods
Approximate Bayesian Computation with Quasi-Likelihoods
 
An Overview of Separation Axioms by Nearly Open Sets in Topology.
An Overview of Separation Axioms by Nearly Open Sets in Topology.An Overview of Separation Axioms by Nearly Open Sets in Topology.
An Overview of Separation Axioms by Nearly Open Sets in Topology.
 
International Refereed Journal of Engineering and Science (IRJES)
International Refereed Journal of Engineering and Science (IRJES)International Refereed Journal of Engineering and Science (IRJES)
International Refereed Journal of Engineering and Science (IRJES)
 
Tuple in python
Tuple in pythonTuple in python
Tuple in python
 

Recently uploaded

Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfakmcokerachita
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 

Recently uploaded (20)

Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdf
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 

Accessing the tuples

  • 1. 1 ACCESSING THE TUPLES Presented by, R.Annalakshmi, 20PA03, 1-MCA, Python programming Accessing the tuples 11-04-2021
  • 2.  A tuple is a collection of objects which ordered and immutable.  Tuples are sequences, just like lists. The differences between tuples and lists are, the tuples cannot be changed unlike lists and tuples use parentheses, whereas lists use square brackets.  tup1 = ('physics', 'chemistry', 1997, 2000);  tup2 = (1, 2, 3, 4, 5 );  tup3 = ("a", "b", "c", "d“); 2 Accessing the tuples 11-04-2021
  • 3.  To access values in tuple, use the square brackets for slicing along with the index or indices to obtain value available at that index. For example  tup1 = ('physics', 'chemistry', 1997, 2000);  tup2 = (1, 2, 3, 4, 5, 6, 7 );  print "tup1[0]: ", tup1[0];  print "tup2[1:5]: ", tup2[1:5];  Output:  tup1[0]: physics  tup2[1:5]: [2, 3, 4, 5] 3 Accessing the tuples 11-04-2021
  • 4.  Tuples are immutable which means you cannot update or change the values of tuple elements. You are able to take portions of existing tuples to create new tuples as,  Example:  tup1 = (12, 34.56);  tup2 = ('abc', 'xyz');  tup3 = tup1 + tup2;  print tup3;  Output:  (12, 34.56, 'abc', 'xyz') 11-04-2021 4 Accessing the tuples
  • 6.  Because tuples are sequences, indexing and slicing work the same way for tuples as they do for strings.  L = ('spam', 'Spam', 'SPAM!') 11-04-2021 6 Accessing the tuples