SlideShare a Scribd company logo
Chapter 13 Tuples.pptx
Computational Thinking and Programming
XI
Computer Science
(083)
Board : CBSE
Courtesy CBSE
Chapter 13 Tuples.pptx
After studying this lesson,
students will be able to:
Understand the need of Tuples;
Solve problems by using Tuples;
 Get clear idea about Tuple functions;
and
Understand the difference between
list, dictionary and tuples.
LEARNING OUTCOMES
WHAT IS TUPLE?
A tuple is a sequence of values,
which can be of any type and they are
indexed by integer. Tuples are just like list,
but we can’t change values of tuples in
place. Thus tuples are immutable.
The index value of tuple starts from 0.
A tuple consists of a number of values
separated by commas. For example:
>>> T=10, 20, 30, 40
>>> print (T)
(10, 20, 30, 40)
WHAT IS TUPLE?
CREATING EMPTY
TUPLE
CREATING EMPTY
TUPLE
ACCESSING TUPLE
ACCESSING TUPLE
ACCESSING TUPLE USING
LOOPS
ACCESSING TUPLE USING
LOOPS
ACCESSING TUPLE USING
LOOPS
OUTPUT
CHECK IF ITEM EXISTS
CHECK IF ITEM EXISTS
OUTPUT
TUPLE LENGTH
TUPLE LENGTH
OUTPUT
REMOVING A TUPLE
REMOVING A TUPLE
You cannot remove or delete or
update items in a tuple.
Tuples are unchangeable, so you
cannot remove items from it, but you can
delete the tuple completely:
NOTE: TUPLES ARE
IMMUTABLE
TUPLE METHODS
TUPLE METHODS
Python provides two built-in
methods that you can use on tuples.
1. count() Method
2. index() Method
TUPLE METHODS
1. count() Method
Return the number of times the value
appears in the tuple Count()
method
returns
total no
times
‘banana’
present in
the given
tuple
TUPLE METHODS
2. index() Method
index() Method returns index
of “banana” i.e 1
index()
Method
DIFFERENCE BETWEEN
LIST AND TUPLE
DIFFERENCE BETWEEN LIST AND TUPLE
LIST TUPLE
Syntax for list is
slightly different
comparing with tuple
Syntax for tuple is
slightly different
comparing with lists
Weekdays=[‘Sun’,’Mo
n’, ‘wed’,46,67]
type(Weekdays)
class<‘lists’>
twdays = (‘Sun’, ‘mon',
‘tue', 634)
type(twdays)
class<‘tuple’>
List uses [ and ]
(square brackets) to
bind the elements.
Tuple uses rounded
brackets( and ) to bind
the elements.
DIFFERENCE BETWEEN LIST AND TUPLE
LIST TUPLE
List can be edited once
it is created in python.
Lists are mutable data
structure.
A tuple is a list which one
cannot edit once it is
created in Python code.
The tuple is an
immutable data structure
More methods or
functions are
associated with lists.
Compare to lists tuples
have Less methods or
functions.
DIFFERENCE BETWEEN
TUPLE AND DICTIONARY
DIFFERENCE BETWEEN TUPLE AND
DICTIONARY
TUPLE DICTIONARY
Order is maintained. Ordering is not
guaranteed.
They are immutable Values in a dictionary can
be changed.
They can hold any
type, and types can be
mixed.
Every entry has a key and
a value
DIFFERENCE BETWEEN TUPLE AND
DICTIONARY
TUPLE DICTIONARY
Elements are accessed
via numeric (zero
based) indices
Elements are accessed
using key's values
There is a difference in
syntax and looks easy
to define tuple
Differ in syntax, looks bit
complicated when
compare with Tuple or
lists
Class Test
PROGRAMS ON TUPLE
BELLOW AVERAGE
PROGRAMS
1. Write a Python program to create a tuple.
#Create an empty tuple
x = ()
print(x)
#Create an empty tuple with tuple() function
#built-in Python
tuplex = tuple()
print(tuplex)
TUPLE - BELLOW AVERAGE
PROGRAMS
2. Write a Python program to create a tuple
with
different data types
#Create a tuple with different data types
tuplex = ("tuple", False, 3.2, 1)
print(tuplex)
TUPLE - BELLOW AVERAGE
PROGRAMS
3. Write a Python program to unpack a tuple
in several variables
#create a tuple
tuplex = 4, 8, 3
print(tuplex)
n1, n2, n3 = tuplex
#unpack a tuple in variables
print(n1 + n2 + n3)
#the number of variables must be equal to
the number of items of the tuple
n1, n2, n3, n4= tuplex
TUPLE - BELLOW AVERAGE
PROGRAMS
TUPLE - AVERAGE PROGRAMS
4 Write a Python program to find the index
of an item of a tuple.
#create a tuple
tuplex = tuple("index tuple")
print(tuplex)
#get index of the first item whose value is
passed as parameter
index = tuplex.index("p")
print(index)
#define the index from which you want to
search
index = tuplex.index("p", 5)
TUPLE - AVERAGE PROGRAMS
print(index)
#define the segment of the tuple to be
searched
index = tuplex.index("e", 3, 6)
print(index)
#if item not exists in the tuple return
ValueError Exception
index = tuplex.index("y")
TUPLE - AVERAGE PROGRAMS
5. Write a Python program to add an item in
a tuple.
#create a tuple
tuplex = (4, 6, 2, 8, 3, 1)
print(tuplex)
#tuples are immutable, so you can not add
new elements
#using merge of tuples with the + operator
you can add an element and it will create a
new tuple
tuplex = tuplex + (9,)
print(tuplex)
TUPLE - AVERAGE PROGRAMS
5. Write a Python program to add an item in
a tuple.
#adding items in a specific index
tuplex = tuplex[:5] + (15, 20, 25) + tuplex[:5]
print(tuplex)
#converting the tuple to list
listx = list(tuplex)
#use different ways to add items in list
listx.append(30)
tuplex = tuple(listx)
print(tuplex)
TUPLE - AVERAGE PROGRAMS
TUPLE – CLASS WORK/ HOME WORK
PROGRAMS
6. Write a Python program to convert a tuple
to a string.
7. Write a Python program to get the 4th
element and 4th element from last of a
tuple.
8. Write a Python program to find the
repeated items of a tuple.
9. Write a Python program to check whether
an element exists within a tuple.
TUPLE - AVERAGE PROGRAMS
Class Test
Time: 40 Min Max Marks: 20
1. What is tuple? give example? 02
2. Write a python script to access a tuple? 05
3. Explain 2 built in methods of?
dictionary? 10
1. Differentiate between tuple and list? 05
Chapter 13 Tuples.pptx

More Related Content

PPTX
Chapter 13 Tuples.pptx
vinnisart
 
PPTX
Chapter 17 Tuples
Praveen M Jigajinni
 
PDF
Python Tuple.pdf
T PRIYA
 
PPTX
Tuples-and-Dictionaries.pptx
AyushTripathi998357
 
PPTX
Tuples.pptx
AnuragBharti27
 
PPTX
Lecture 09.pptx
Mohammad Hassan
 
PPTX
Tuples class 11 notes- important notes for tuple lesson
nikkitas041409
 
Chapter 13 Tuples.pptx
vinnisart
 
Chapter 17 Tuples
Praveen M Jigajinni
 
Python Tuple.pdf
T PRIYA
 
Tuples-and-Dictionaries.pptx
AyushTripathi998357
 
Tuples.pptx
AnuragBharti27
 
Lecture 09.pptx
Mohammad Hassan
 
Tuples class 11 notes- important notes for tuple lesson
nikkitas041409
 

Similar to Chapter 13 Tuples.pptx (20)

PDF
Python Is Very most Important for Your Life Time.
SravaniSravani53
 
PDF
Tuple in Python class documnet pritened.
SravaniSravani53
 
PPTX
UNIT-3 python and data structure alo.pptx
harikahhy
 
PDF
tuples chapter (1).pdfhsuenduneudhhsbhhd
megaladsmegala
 
PPT
Programming in Python Lists and its methods .ppt
Dr. Jasmine Beulah Gnanadurai
 
PPTX
PYTHON LISTsjnjsnljnsjnosojnosojnsojnsjsn.pptx
surajnath20
 
PPTX
Python Collections
sachingarg0
 
PDF
updated_tuple_in_python.pdf
Koteswari Kasireddy
 
PDF
Python tuple
Mohammed Sikander
 
PDF
Python tuples and Dictionary
Aswini Dharmaraj
 
PDF
Python data handling notes
Prof. Dr. K. Adisesha
 
PPTX
tupple.pptx
satyabratPanda2
 
PDF
Python list
Prof. Dr. K. Adisesha
 
PDF
‘How to develop Pythonic coding rather than Python coding – Logic Perspective’
S.Mohideen Badhusha
 
PDF
Python Tuples
Soba Arjun
 
PPT
List.ppt
VIBITHAS3
 
PPTX
Tuples in python better understanding with slides
chaudharyaamirm
 
PPTX
tuple in python is an impotant topic.pptx
urvashipundir04
 
PPT
TUPLE.ppt
UnknownPerson930271
 
PPTX
PRESENTATION ON TUPLES.pptx
rohan899711
 
Python Is Very most Important for Your Life Time.
SravaniSravani53
 
Tuple in Python class documnet pritened.
SravaniSravani53
 
UNIT-3 python and data structure alo.pptx
harikahhy
 
tuples chapter (1).pdfhsuenduneudhhsbhhd
megaladsmegala
 
Programming in Python Lists and its methods .ppt
Dr. Jasmine Beulah Gnanadurai
 
PYTHON LISTsjnjsnljnsjnosojnosojnsojnsjsn.pptx
surajnath20
 
Python Collections
sachingarg0
 
updated_tuple_in_python.pdf
Koteswari Kasireddy
 
Python tuple
Mohammed Sikander
 
Python tuples and Dictionary
Aswini Dharmaraj
 
Python data handling notes
Prof. Dr. K. Adisesha
 
tupple.pptx
satyabratPanda2
 
‘How to develop Pythonic coding rather than Python coding – Logic Perspective’
S.Mohideen Badhusha
 
Python Tuples
Soba Arjun
 
List.ppt
VIBITHAS3
 
Tuples in python better understanding with slides
chaudharyaamirm
 
tuple in python is an impotant topic.pptx
urvashipundir04
 
PRESENTATION ON TUPLES.pptx
rohan899711
 
Ad

Recently uploaded (20)

PPTX
AI in Daily Life: How Artificial Intelligence Helps Us Every Day
vanshrpatil7
 
PDF
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
PDF
Brief History of Internet - Early Days of Internet
sutharharshit158
 
PPTX
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
PDF
OFFOFFBOX™ – A New Era for African Film | Startup Presentation
ambaicciwalkerbrian
 
PDF
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
 
PDF
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
PDF
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
PDF
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
PDF
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
PDF
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
PPTX
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
PDF
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
PPTX
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
PDF
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
PPTX
Agile Chennai 18-19 July 2025 Ideathon | AI Powered Microfinance Literacy Gui...
AgileNetwork
 
PDF
Doc9.....................................
SofiaCollazos
 
PPTX
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PDF
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
AI in Daily Life: How Artificial Intelligence Helps Us Every Day
vanshrpatil7
 
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
Brief History of Internet - Early Days of Internet
sutharharshit158
 
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
OFFOFFBOX™ – A New Era for African Film | Startup Presentation
ambaicciwalkerbrian
 
Orbitly Pitch Deck|A Mission-Driven Platform for Side Project Collaboration (...
zz41354899
 
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
Agile Chennai 18-19 July 2025 Ideathon | AI Powered Microfinance Literacy Gui...
AgileNetwork
 
Doc9.....................................
SofiaCollazos
 
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
Ad

Chapter 13 Tuples.pptx

  • 2. Computational Thinking and Programming XI Computer Science (083) Board : CBSE Courtesy CBSE
  • 4. After studying this lesson, students will be able to: Understand the need of Tuples; Solve problems by using Tuples;  Get clear idea about Tuple functions; and Understand the difference between list, dictionary and tuples. LEARNING OUTCOMES
  • 6. A tuple is a sequence of values, which can be of any type and they are indexed by integer. Tuples are just like list, but we can’t change values of tuples in place. Thus tuples are immutable. The index value of tuple starts from 0. A tuple consists of a number of values separated by commas. For example: >>> T=10, 20, 30, 40 >>> print (T) (10, 20, 30, 40) WHAT IS TUPLE?
  • 14. CHECK IF ITEM EXISTS
  • 15. CHECK IF ITEM EXISTS OUTPUT
  • 19. REMOVING A TUPLE You cannot remove or delete or update items in a tuple. Tuples are unchangeable, so you cannot remove items from it, but you can delete the tuple completely: NOTE: TUPLES ARE IMMUTABLE
  • 21. TUPLE METHODS Python provides two built-in methods that you can use on tuples. 1. count() Method 2. index() Method
  • 22. TUPLE METHODS 1. count() Method Return the number of times the value appears in the tuple Count() method returns total no times ‘banana’ present in the given tuple
  • 23. TUPLE METHODS 2. index() Method index() Method returns index of “banana” i.e 1 index() Method
  • 25. DIFFERENCE BETWEEN LIST AND TUPLE LIST TUPLE Syntax for list is slightly different comparing with tuple Syntax for tuple is slightly different comparing with lists Weekdays=[‘Sun’,’Mo n’, ‘wed’,46,67] type(Weekdays) class<‘lists’> twdays = (‘Sun’, ‘mon', ‘tue', 634) type(twdays) class<‘tuple’> List uses [ and ] (square brackets) to bind the elements. Tuple uses rounded brackets( and ) to bind the elements.
  • 26. DIFFERENCE BETWEEN LIST AND TUPLE LIST TUPLE List can be edited once it is created in python. Lists are mutable data structure. A tuple is a list which one cannot edit once it is created in Python code. The tuple is an immutable data structure More methods or functions are associated with lists. Compare to lists tuples have Less methods or functions.
  • 28. DIFFERENCE BETWEEN TUPLE AND DICTIONARY TUPLE DICTIONARY Order is maintained. Ordering is not guaranteed. They are immutable Values in a dictionary can be changed. They can hold any type, and types can be mixed. Every entry has a key and a value
  • 29. DIFFERENCE BETWEEN TUPLE AND DICTIONARY TUPLE DICTIONARY Elements are accessed via numeric (zero based) indices Elements are accessed using key's values There is a difference in syntax and looks easy to define tuple Differ in syntax, looks bit complicated when compare with Tuple or lists
  • 31. PROGRAMS ON TUPLE BELLOW AVERAGE PROGRAMS
  • 32. 1. Write a Python program to create a tuple. #Create an empty tuple x = () print(x) #Create an empty tuple with tuple() function #built-in Python tuplex = tuple() print(tuplex) TUPLE - BELLOW AVERAGE PROGRAMS
  • 33. 2. Write a Python program to create a tuple with different data types #Create a tuple with different data types tuplex = ("tuple", False, 3.2, 1) print(tuplex) TUPLE - BELLOW AVERAGE PROGRAMS
  • 34. 3. Write a Python program to unpack a tuple in several variables #create a tuple tuplex = 4, 8, 3 print(tuplex) n1, n2, n3 = tuplex #unpack a tuple in variables print(n1 + n2 + n3) #the number of variables must be equal to the number of items of the tuple n1, n2, n3, n4= tuplex TUPLE - BELLOW AVERAGE PROGRAMS
  • 35. TUPLE - AVERAGE PROGRAMS
  • 36. 4 Write a Python program to find the index of an item of a tuple. #create a tuple tuplex = tuple("index tuple") print(tuplex) #get index of the first item whose value is passed as parameter index = tuplex.index("p") print(index) #define the index from which you want to search index = tuplex.index("p", 5) TUPLE - AVERAGE PROGRAMS
  • 37. print(index) #define the segment of the tuple to be searched index = tuplex.index("e", 3, 6) print(index) #if item not exists in the tuple return ValueError Exception index = tuplex.index("y") TUPLE - AVERAGE PROGRAMS
  • 38. 5. Write a Python program to add an item in a tuple. #create a tuple tuplex = (4, 6, 2, 8, 3, 1) print(tuplex) #tuples are immutable, so you can not add new elements #using merge of tuples with the + operator you can add an element and it will create a new tuple tuplex = tuplex + (9,) print(tuplex) TUPLE - AVERAGE PROGRAMS
  • 39. 5. Write a Python program to add an item in a tuple. #adding items in a specific index tuplex = tuplex[:5] + (15, 20, 25) + tuplex[:5] print(tuplex) #converting the tuple to list listx = list(tuplex) #use different ways to add items in list listx.append(30) tuplex = tuple(listx) print(tuplex) TUPLE - AVERAGE PROGRAMS
  • 40. TUPLE – CLASS WORK/ HOME WORK PROGRAMS
  • 41. 6. Write a Python program to convert a tuple to a string. 7. Write a Python program to get the 4th element and 4th element from last of a tuple. 8. Write a Python program to find the repeated items of a tuple. 9. Write a Python program to check whether an element exists within a tuple. TUPLE - AVERAGE PROGRAMS
  • 42. Class Test Time: 40 Min Max Marks: 20 1. What is tuple? give example? 02 2. Write a python script to access a tuple? 05 3. Explain 2 built in methods of? dictionary? 10 1. Differentiate between tuple and list? 05