SlideShare a Scribd company logo
1 of 15
PYTHON DATA
STRUCTURE
TEL 122 TKE 144 Pemrograman Komputer
Python Common
data types
• Number
• String
• List
• Tuple
• Dictionary
• set
Python data types are
classified into the
following types:
• Sequential: Subscripts (indexes) can be used to
access elements. You can access elements in
slice mode such as [start:stop:step].
• Nonsequential: Subscripts (indexes) cannot be
used to access elements.
• Changeable: Values can be modified.
• Unchangeable:Values cannot be modified.
Number, basic operation
Addition (+)
Subtraction (-)
Multiplication (x)
Division (/)
Modulo/Rounding (%, //)
Power (**)
If the operation is performed on numbers of
different types (such as int and float), the result
type is the type with higher precision.
Math operation
STRING
• In Python, a string is a sequence with multiple characters.
• The number of characters indicates the length of the string.
• Python does not have a character data type. A single character
is considered as a string with length 1.
• To declare a string, you only need to
• use single quotation marks ('...') or
• double quotation marks ("...") to enclose the content, or
• three consecutive quotation marks ('''...''' or """...""").
String Operator (1)
• : Two strings are concatenated.
• Example: a="hello";b="world" =>a+b= 'helloworld'.
• *: A new string is obtained by multiplying a string by a number.
• Example: "a"*2=>"aa"
String Operator (2)
String Operator (3)
String Operator (4)
List
• A list is a sequence in which elements can be of any data type
and elements can be added or deleted at any time.
• In a list, elements are enclosed by a pair of square brackets and
are separated by commas (,). You can create a list in either of
the following ways:
• List = list(obj1, obj2,…)
• List = [obj1, obj2, ….]
• Operator:
• +: Combines lists, for example, the result of [1,2]+[2,3] is [1, 2, 2, 3].
• x: Multiplies a list by a number to obtain a new list, for example, the result of [1,2] x 2
is [1, 2, 1, 2].
List Operator (1)
List Operator (2)
Example Operator List
animals = ['cat', 'dog', 'monkey']
# list.append(obj): Add a new object to the end of the list.
animals.append ('fish') # Append an element.
print(animals) # Output: ['cat', 'dog', 'monkey', ‘fish’]
# list.remove(obj): Remove the first match for a value in the list.
animals.remove ('fish') # Delete element fish.
print(animals) # Output: ['cat', 'dog', 'monkey']
# list.insert(index, obj): Insert a specified object to a specified position in the list. The index
indicates the position.
animals.insert (1, 'fish') # Insert element fish at subscript 1.
print(animals) # Output: ['cat', ‘fish’, 'dog', 'monkey']
Next
• Tuple, Dictinary, Set

More Related Content

Similar to 02 Python Data Structure.pptx

RANDOMISATION-NUMERICAL METHODS FOR ENGINEERING.pptx
RANDOMISATION-NUMERICAL METHODS  FOR ENGINEERING.pptxRANDOMISATION-NUMERICAL METHODS  FOR ENGINEERING.pptx
RANDOMISATION-NUMERICAL METHODS FOR ENGINEERING.pptx
Out Cast
 
11 Introduction to lists.pptx
11 Introduction to lists.pptx11 Introduction to lists.pptx
11 Introduction to lists.pptx
ssuser8e50d8
 
Python Unit 5 Questions n Notes.pdf
Python Unit 5 Questions n Notes.pdfPython Unit 5 Questions n Notes.pdf
Python Unit 5 Questions n Notes.pdf
MCCMOTOR
 

Similar to 02 Python Data Structure.pptx (20)

2. Values and Data types in Python.pptx
2. Values and Data types in Python.pptx2. Values and Data types in Python.pptx
2. Values and Data types in Python.pptx
 
RANDOMISATION-NUMERICAL METHODS FOR ENGINEERING.pptx
RANDOMISATION-NUMERICAL METHODS  FOR ENGINEERING.pptxRANDOMISATION-NUMERICAL METHODS  FOR ENGINEERING.pptx
RANDOMISATION-NUMERICAL METHODS FOR ENGINEERING.pptx
 
Python standard data types
Python standard data typesPython standard data types
Python standard data types
 
11 Introduction to lists.pptx
11 Introduction to lists.pptx11 Introduction to lists.pptx
11 Introduction to lists.pptx
 
Lists python.pptx
Lists python.pptxLists python.pptx
Lists python.pptx
 
updated_list.pptx
updated_list.pptxupdated_list.pptx
updated_list.pptx
 
Python Session - 3
Python Session - 3Python Session - 3
Python Session - 3
 
Datatypes in Python.pdf
Datatypes in Python.pdfDatatypes in Python.pdf
Datatypes in Python.pdf
 
Module 2 - Lists, Tuples, Files.pptx
Module 2 - Lists, Tuples, Files.pptxModule 2 - Lists, Tuples, Files.pptx
Module 2 - Lists, Tuples, Files.pptx
 
Python revision tour II
Python revision tour IIPython revision tour II
Python revision tour II
 
Python Data-Types
Python Data-TypesPython Data-Types
Python Data-Types
 
updated_tuple_in_python.pdf
updated_tuple_in_python.pdfupdated_tuple_in_python.pdf
updated_tuple_in_python.pdf
 
Data type list_methods_in_python
Data type list_methods_in_pythonData type list_methods_in_python
Data type list_methods_in_python
 
Python Unit 5 Questions n Notes.pdf
Python Unit 5 Questions n Notes.pdfPython Unit 5 Questions n Notes.pdf
Python Unit 5 Questions n Notes.pdf
 
List , tuples, dictionaries and regular expressions in python
List , tuples, dictionaries and regular expressions in pythonList , tuples, dictionaries and regular expressions in python
List , tuples, dictionaries and regular expressions in python
 
Python Data Types.pdf
Python Data Types.pdfPython Data Types.pdf
Python Data Types.pdf
 
Python Data Types (1).pdf
Python Data Types (1).pdfPython Data Types (1).pdf
Python Data Types (1).pdf
 
Programming in Python
Programming in Python Programming in Python
Programming in Python
 
Lecture-15-Tuples-and-Dictionaries-Oct23-2018.pptx
Lecture-15-Tuples-and-Dictionaries-Oct23-2018.pptxLecture-15-Tuples-and-Dictionaries-Oct23-2018.pptx
Lecture-15-Tuples-and-Dictionaries-Oct23-2018.pptx
 
Python data handling notes
Python data handling notesPython data handling notes
Python data handling notes
 

Recently uploaded

Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Kandungan 087776558899
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
Hospital management system project report.pdf
Hospital management system project report.pdfHospital management system project report.pdf
Hospital management system project report.pdf
Kamal Acharya
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
mphochane1998
 

Recently uploaded (20)

Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
PE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiesPE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and properties
 
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptxA CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
 
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxHOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
 
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARHAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna Municipality
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
 
Moment Distribution Method For Btech Civil
Moment Distribution Method For Btech CivilMoment Distribution Method For Btech Civil
Moment Distribution Method For Btech Civil
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS Lambda
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.
 
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
Hospital management system project report.pdf
Hospital management system project report.pdfHospital management system project report.pdf
Hospital management system project report.pdf
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdf
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equation
 

02 Python Data Structure.pptx

  • 1. PYTHON DATA STRUCTURE TEL 122 TKE 144 Pemrograman Komputer
  • 2. Python Common data types • Number • String • List • Tuple • Dictionary • set
  • 3. Python data types are classified into the following types: • Sequential: Subscripts (indexes) can be used to access elements. You can access elements in slice mode such as [start:stop:step]. • Nonsequential: Subscripts (indexes) cannot be used to access elements. • Changeable: Values can be modified. • Unchangeable:Values cannot be modified.
  • 4. Number, basic operation Addition (+) Subtraction (-) Multiplication (x) Division (/) Modulo/Rounding (%, //) Power (**) If the operation is performed on numbers of different types (such as int and float), the result type is the type with higher precision.
  • 6. STRING • In Python, a string is a sequence with multiple characters. • The number of characters indicates the length of the string. • Python does not have a character data type. A single character is considered as a string with length 1. • To declare a string, you only need to • use single quotation marks ('...') or • double quotation marks ("...") to enclose the content, or • three consecutive quotation marks ('''...''' or """...""").
  • 7. String Operator (1) • : Two strings are concatenated. • Example: a="hello";b="world" =>a+b= 'helloworld'. • *: A new string is obtained by multiplying a string by a number. • Example: "a"*2=>"aa"
  • 11. List • A list is a sequence in which elements can be of any data type and elements can be added or deleted at any time. • In a list, elements are enclosed by a pair of square brackets and are separated by commas (,). You can create a list in either of the following ways: • List = list(obj1, obj2,…) • List = [obj1, obj2, ….] • Operator: • +: Combines lists, for example, the result of [1,2]+[2,3] is [1, 2, 2, 3]. • x: Multiplies a list by a number to obtain a new list, for example, the result of [1,2] x 2 is [1, 2, 1, 2].
  • 14. Example Operator List animals = ['cat', 'dog', 'monkey'] # list.append(obj): Add a new object to the end of the list. animals.append ('fish') # Append an element. print(animals) # Output: ['cat', 'dog', 'monkey', ‘fish’] # list.remove(obj): Remove the first match for a value in the list. animals.remove ('fish') # Delete element fish. print(animals) # Output: ['cat', 'dog', 'monkey'] # list.insert(index, obj): Insert a specified object to a specified position in the list. The index indicates the position. animals.insert (1, 'fish') # Insert element fish at subscript 1. print(animals) # Output: ['cat', ‘fish’, 'dog', 'monkey']