Suche senden
Hochladen
Python Programming Essentials - M12 - Lists
•
3 gefällt mir
•
2,094 views
P3 InfoTech Solutions Pvt. Ltd.
Folgen
Slides from the training on the topic "Python Programming Essentials"
Weniger lesen
Mehr lesen
Technologie
Melden
Teilen
Melden
Teilen
1 von 22
Empfohlen
Arrays
Arrays
archikabhatia
Arrays in python
Arrays in python
moazamali28
Python array
Python array
Arnab Chakraborty
Python list
Python list
Mohammed Sikander
Unit 4 python -list methods
Unit 4 python -list methods
narmadhakin
1.5 binary search tree
1.5 binary search tree
Krish_ver2
Map, Filter and Reduce In Python
Map, Filter and Reduce In Python
Simplilearn
Lists
Lists
Lakshmi Sarvani Videla
Empfohlen
Arrays
Arrays
archikabhatia
Arrays in python
Arrays in python
moazamali28
Python array
Python array
Arnab Chakraborty
Python list
Python list
Mohammed Sikander
Unit 4 python -list methods
Unit 4 python -list methods
narmadhakin
1.5 binary search tree
1.5 binary search tree
Krish_ver2
Map, Filter and Reduce In Python
Map, Filter and Reduce In Python
Simplilearn
Lists
Lists
Lakshmi Sarvani Videla
16. Java stacks and queues
16. Java stacks and queues
Intro C# Book
Arrays In Python | Python Array Operations | Edureka
Arrays In Python | Python Array Operations | Edureka
Edureka!
Queues
Queues
Ashim Lamichhane
List in Python
List in Python
Siddique Ibrahim
Expression evaluation
Expression evaluation
JeeSa Sultana
Presentation on queue
Presentation on queue
Rojan Pariyar
sorting and searching.pptx
sorting and searching.pptx
ParagAhir1
Datastructures in python
Datastructures in python
hydpy
C++ Arrays
C++ Arrays
أحمد محمد
17. Java data structures trees representation and traversal
17. Java data structures trees representation and traversal
Intro C# Book
Introduction to Array ppt
Introduction to Array ppt
sandhya yadav
Priority queues
Priority queues
Priyanka Rana
Python programming : List and tuples
Python programming : List and tuples
Emertxe Information Technologies Pvt Ltd
List in Python
List in Python
Sharath Ankrajegowda
Python Programming
Python Programming
Sreedhar Chowdam
Basic data structures in python
Basic data structures in python
Celine George
Queue data structure
Queue data structure
anooppjoseph
9 python data structure-2
9 python data structure-2
Prof. Dr. K. Adisesha
Chapter 07 inheritance
Chapter 07 inheritance
Praveen M Jigajinni
Java Foundations: Maps, Lambda and Stream API
Java Foundations: Maps, Lambda and Stream API
Svetlin Nakov
Class 7: Programming with Lists
Class 7: Programming with Lists
David Evans
Python002
Python002
Shahjalal Hossain
Weitere ähnliche Inhalte
Was ist angesagt?
16. Java stacks and queues
16. Java stacks and queues
Intro C# Book
Arrays In Python | Python Array Operations | Edureka
Arrays In Python | Python Array Operations | Edureka
Edureka!
Queues
Queues
Ashim Lamichhane
List in Python
List in Python
Siddique Ibrahim
Expression evaluation
Expression evaluation
JeeSa Sultana
Presentation on queue
Presentation on queue
Rojan Pariyar
sorting and searching.pptx
sorting and searching.pptx
ParagAhir1
Datastructures in python
Datastructures in python
hydpy
C++ Arrays
C++ Arrays
أحمد محمد
17. Java data structures trees representation and traversal
17. Java data structures trees representation and traversal
Intro C# Book
Introduction to Array ppt
Introduction to Array ppt
sandhya yadav
Priority queues
Priority queues
Priyanka Rana
Python programming : List and tuples
Python programming : List and tuples
Emertxe Information Technologies Pvt Ltd
List in Python
List in Python
Sharath Ankrajegowda
Python Programming
Python Programming
Sreedhar Chowdam
Basic data structures in python
Basic data structures in python
Celine George
Queue data structure
Queue data structure
anooppjoseph
9 python data structure-2
9 python data structure-2
Prof. Dr. K. Adisesha
Chapter 07 inheritance
Chapter 07 inheritance
Praveen M Jigajinni
Java Foundations: Maps, Lambda and Stream API
Java Foundations: Maps, Lambda and Stream API
Svetlin Nakov
Was ist angesagt?
(20)
16. Java stacks and queues
16. Java stacks and queues
Arrays In Python | Python Array Operations | Edureka
Arrays In Python | Python Array Operations | Edureka
Queues
Queues
List in Python
List in Python
Expression evaluation
Expression evaluation
Presentation on queue
Presentation on queue
sorting and searching.pptx
sorting and searching.pptx
Datastructures in python
Datastructures in python
C++ Arrays
C++ Arrays
17. Java data structures trees representation and traversal
17. Java data structures trees representation and traversal
Introduction to Array ppt
Introduction to Array ppt
Priority queues
Priority queues
Python programming : List and tuples
Python programming : List and tuples
List in Python
List in Python
Python Programming
Python Programming
Basic data structures in python
Basic data structures in python
Queue data structure
Queue data structure
9 python data structure-2
9 python data structure-2
Chapter 07 inheritance
Chapter 07 inheritance
Java Foundations: Maps, Lambda and Stream API
Java Foundations: Maps, Lambda and Stream API
Andere mochten auch
Class 7: Programming with Lists
Class 7: Programming with Lists
David Evans
Python002
Python002
Shahjalal Hossain
An Introduction To Python - Dictionaries
An Introduction To Python - Dictionaries
Blue Elephant Consulting
Python Workshop Part 2. LUG Maniapl
Python Workshop Part 2. LUG Maniapl
Ankur Shrivastava
Dictionaries in Python
Dictionaries in Python
baabtra.com - No. 1 supplier of quality freshers
Python Programming and GIS
Python Programming and GIS
John Reiser
Python Worst Practices
Python Worst Practices
Daniel Greenfeld
Introduction to Python
Introduction to Python
Nowell Strite
Andere mochten auch
(8)
Class 7: Programming with Lists
Class 7: Programming with Lists
Python002
Python002
An Introduction To Python - Dictionaries
An Introduction To Python - Dictionaries
Python Workshop Part 2. LUG Maniapl
Python Workshop Part 2. LUG Maniapl
Dictionaries in Python
Dictionaries in Python
Python Programming and GIS
Python Programming and GIS
Python Worst Practices
Python Worst Practices
Introduction to Python
Introduction to Python
Ähnlich wie Python Programming Essentials - M12 - Lists
Unit - 4.ppt
Unit - 4.ppt
Kongunadu College of Engineering and Technology
Pythonlearn-08-Lists.pptx
Pythonlearn-08-Lists.pptx
MihirDatir1
R Data Structure.pptx
R Data Structure.pptx
DIT University, Dehradun
Pa1 session 3_slides
Pa1 session 3_slides
aiclub_slides
Python Programming: Lists, Modules, Exceptions
Python Programming: Lists, Modules, Exceptions
Sreedhar Chowdam
Python Lecture 8
Python Lecture 8
Inzamam Baig
جلسه سوم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲
جلسه سوم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲
Mohammad Reza Kamalifard
6. list
6. list
PhD Research Scholar
Python programming workshop session 3
Python programming workshop session 3
Abdul Haseeb
UNIT III_Python Programming_aditya COllege
UNIT III_Python Programming_aditya COllege
Ramanamurthy Banda
UNIT III_Python Programming_aditya COllege
UNIT III_Python Programming_aditya COllege
Ramanamurthy Banda
Pythonlearn-08-Lists.pptx
Pythonlearn-08-Lists.pptx
MihirDatir
list and control statement.pptx
list and control statement.pptx
ssuser8f0410
Lists.pptx
Lists.pptx
Yagna15
PureScript & Pux
PureScript & Pux
Arthur Xavier
Python Training
Python Training
TIB Academy
R programming
R programming
Pramodkumar Jha
Python elements list you can study .pdf
Python elements list you can study .pdf
AUNGHTET61
8799.pdfOr else the work is fine only. Lot to learn buddy.... Improve your ba...
8799.pdfOr else the work is fine only. Lot to learn buddy.... Improve your ba...
Yashpatel821746
Or else the work is fine only. Lot to learn buddy.... Improve your basics in ...
Or else the work is fine only. Lot to learn buddy.... Improve your basics in ...
Yashpatel821746
Ähnlich wie Python Programming Essentials - M12 - Lists
(20)
Unit - 4.ppt
Unit - 4.ppt
Pythonlearn-08-Lists.pptx
Pythonlearn-08-Lists.pptx
R Data Structure.pptx
R Data Structure.pptx
Pa1 session 3_slides
Pa1 session 3_slides
Python Programming: Lists, Modules, Exceptions
Python Programming: Lists, Modules, Exceptions
Python Lecture 8
Python Lecture 8
جلسه سوم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲
جلسه سوم پایتون برای هکر های قانونی دوره مقدماتی پاییز ۹۲
6. list
6. list
Python programming workshop session 3
Python programming workshop session 3
UNIT III_Python Programming_aditya COllege
UNIT III_Python Programming_aditya COllege
UNIT III_Python Programming_aditya COllege
UNIT III_Python Programming_aditya COllege
Pythonlearn-08-Lists.pptx
Pythonlearn-08-Lists.pptx
list and control statement.pptx
list and control statement.pptx
Lists.pptx
Lists.pptx
PureScript & Pux
PureScript & Pux
Python Training
Python Training
R programming
R programming
Python elements list you can study .pdf
Python elements list you can study .pdf
8799.pdfOr else the work is fine only. Lot to learn buddy.... Improve your ba...
8799.pdfOr else the work is fine only. Lot to learn buddy.... Improve your ba...
Or else the work is fine only. Lot to learn buddy.... Improve your basics in ...
Or else the work is fine only. Lot to learn buddy.... Improve your basics in ...
Mehr von P3 InfoTech Solutions Pvt. Ltd.
Python Programming Essentials - M44 - Overview of Web Development
Python Programming Essentials - M44 - Overview of Web Development
P3 InfoTech Solutions Pvt. Ltd.
Python Programming Essentials - M40 - Invoking External Programs
Python Programming Essentials - M40 - Invoking External Programs
P3 InfoTech Solutions Pvt. Ltd.
Python Programming Essentials - M39 - Unit Testing
Python Programming Essentials - M39 - Unit Testing
P3 InfoTech Solutions Pvt. Ltd.
Python Programming Essentials - M37 - Brief Overview of Misc Concepts
Python Programming Essentials - M37 - Brief Overview of Misc Concepts
P3 InfoTech Solutions Pvt. Ltd.
Python Programming Essentials - M35 - Iterators & Generators
Python Programming Essentials - M35 - Iterators & Generators
P3 InfoTech Solutions Pvt. Ltd.
Python Programming Essentials - M34 - List Comprehensions
Python Programming Essentials - M34 - List Comprehensions
P3 InfoTech Solutions Pvt. Ltd.
Python Programming Essentials - M31 - PEP 8
Python Programming Essentials - M31 - PEP 8
P3 InfoTech Solutions Pvt. Ltd.
Python Programming Essentials - M29 - Python Interpreter and Files
Python Programming Essentials - M29 - Python Interpreter and Files
P3 InfoTech Solutions Pvt. Ltd.
Python Programming Essentials - M28 - Debugging with pdb
Python Programming Essentials - M28 - Debugging with pdb
P3 InfoTech Solutions Pvt. Ltd.
Python Programming Essentials - M27 - Logging module
Python Programming Essentials - M27 - Logging module
P3 InfoTech Solutions Pvt. Ltd.
Python Programming Essentials - M25 - os and sys modules
Python Programming Essentials - M25 - os and sys modules
P3 InfoTech Solutions Pvt. Ltd.
Python Programming Essentials - M24 - math module
Python Programming Essentials - M24 - math module
P3 InfoTech Solutions Pvt. Ltd.
Python Programming Essentials - M23 - datetime module
Python Programming Essentials - M23 - datetime module
P3 InfoTech Solutions Pvt. Ltd.
Python Programming Essentials - M22 - File Operations
Python Programming Essentials - M22 - File Operations
P3 InfoTech Solutions Pvt. Ltd.
Python Programming Essentials - M21 - Exception Handling
Python Programming Essentials - M21 - Exception Handling
P3 InfoTech Solutions Pvt. Ltd.
Python Programming Essentials - M20 - Classes and Objects
Python Programming Essentials - M20 - Classes and Objects
P3 InfoTech Solutions Pvt. Ltd.
Python Programming Essentials - M19 - Namespaces, Global Variables and Docstr...
Python Programming Essentials - M19 - Namespaces, Global Variables and Docstr...
P3 InfoTech Solutions Pvt. Ltd.
Python Programming Essentials - M18 - Modules and Packages
Python Programming Essentials - M18 - Modules and Packages
P3 InfoTech Solutions Pvt. Ltd.
Python Programming Essentials - M17 - Functions
Python Programming Essentials - M17 - Functions
P3 InfoTech Solutions Pvt. Ltd.
Python Programming Essentials - M16 - Control Flow Statements and Loops
Python Programming Essentials - M16 - Control Flow Statements and Loops
P3 InfoTech Solutions Pvt. Ltd.
Mehr von P3 InfoTech Solutions Pvt. Ltd.
(20)
Python Programming Essentials - M44 - Overview of Web Development
Python Programming Essentials - M44 - Overview of Web Development
Python Programming Essentials - M40 - Invoking External Programs
Python Programming Essentials - M40 - Invoking External Programs
Python Programming Essentials - M39 - Unit Testing
Python Programming Essentials - M39 - Unit Testing
Python Programming Essentials - M37 - Brief Overview of Misc Concepts
Python Programming Essentials - M37 - Brief Overview of Misc Concepts
Python Programming Essentials - M35 - Iterators & Generators
Python Programming Essentials - M35 - Iterators & Generators
Python Programming Essentials - M34 - List Comprehensions
Python Programming Essentials - M34 - List Comprehensions
Python Programming Essentials - M31 - PEP 8
Python Programming Essentials - M31 - PEP 8
Python Programming Essentials - M29 - Python Interpreter and Files
Python Programming Essentials - M29 - Python Interpreter and Files
Python Programming Essentials - M28 - Debugging with pdb
Python Programming Essentials - M28 - Debugging with pdb
Python Programming Essentials - M27 - Logging module
Python Programming Essentials - M27 - Logging module
Python Programming Essentials - M25 - os and sys modules
Python Programming Essentials - M25 - os and sys modules
Python Programming Essentials - M24 - math module
Python Programming Essentials - M24 - math module
Python Programming Essentials - M23 - datetime module
Python Programming Essentials - M23 - datetime module
Python Programming Essentials - M22 - File Operations
Python Programming Essentials - M22 - File Operations
Python Programming Essentials - M21 - Exception Handling
Python Programming Essentials - M21 - Exception Handling
Python Programming Essentials - M20 - Classes and Objects
Python Programming Essentials - M20 - Classes and Objects
Python Programming Essentials - M19 - Namespaces, Global Variables and Docstr...
Python Programming Essentials - M19 - Namespaces, Global Variables and Docstr...
Python Programming Essentials - M18 - Modules and Packages
Python Programming Essentials - M18 - Modules and Packages
Python Programming Essentials - M17 - Functions
Python Programming Essentials - M17 - Functions
Python Programming Essentials - M16 - Control Flow Statements and Loops
Python Programming Essentials - M16 - Control Flow Statements and Loops
Kürzlich hochgeladen
presentation ICT roal in 21st century education
presentation ICT roal in 21st century education
jfdjdjcjdnsjd
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
Remote DBA Services
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
apidays
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Miguel Araújo
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
Rafal Los
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
Radu Cotescu
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
Principled Technologies
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
Safe Software
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
Maria Levchenko
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
The Digital Insurer
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
Boston Institute of Analytics
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Drew Madelung
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
wesley chun
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
apidays
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
Gabriella Davis
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
Michael W. Hawkins
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
The Digital Insurer
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
Andrey Devyatkin
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
The Digital Insurer
Kürzlich hochgeladen
(20)
presentation ICT roal in 21st century education
presentation ICT roal in 21st century education
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
Python Programming Essentials - M12 - Lists
1.
http://www.skillbrew.com /SkillbrewTalent brewed by
the industry itself Python Lists and references Pavan Verma @YinYangPavan Python Programming Essentials
2.
© SkillBrew http://skillbrew.com Python
lists List is an ordered collections of items Item could be any Python data type (strings, number, other lists, tuple, dictionary) Similar to arrays in (C / JAVA / C++) Lists are the simplest data structure in Python colors = [‘red’, ‘blue’, ‘green’] 2
3.
© SkillBrew http://skillbrew.com List
creation Use square brackets [] to create a list 3 >>> colors = ['red', 'blue', 'green'] >>> colors Output: ['red', 'blue', 'green']
4.
© SkillBrew http://skillbrew.com Access
List Elements list[index] 4 >>> colors = ['red', 'blue', 'green'] >>> colors ['red', 'blue', 'green'] >>> colors[0] 'red' >>> colors[1] 'blue' >>> colors[2] 'green'
5.
© SkillBrew http://skillbrew.com Negative
Indexes list[-index] 5 >>> colors = ['red', 'blue', 'green'] >>> colors ['red', 'blue', 'green'] >>> colors[-1] 'green' >>> colors[-2] 'blue' >>> colors[-3] 'red'
6.
© SkillBrew http://skillbrew.com List
operations length append insert remove delete pop Slicing 6
7.
© SkillBrew http://skillbrew.com Length
of a list Use len()function to get the length of list 7 >>> colors = ['red', 'blue', 'green'] >>> len(colors) Output: 3
8.
© SkillBrew http://skillbrew.com Append
an element Use append() to add an element to the list append adds the element at the end of a list 8 >>> colors = ['red', 'blue', 'green'] >>> colors.append('orange') >>> colors ['red', 'blue', 'green', 'orange']
9.
© SkillBrew http://skillbrew.com Insert
an element at an index list.insert(index, value) Use insert to insert an element at a particular index 9 >>> colors ['red', 'blue', 'green', 'orange'] >>> colors.insert(1, 'black') >>> colors ['red', 'black', 'blue', 'green', 'orange']
10.
© SkillBrew http://skillbrew.com Remove
an element from list remove(x) removes the first item from the list whose value is x 10 >>> colors ['red', 'black', 'blue', 'green', 'orange'] >>> colors.remove('black') >>> colors ['red', 'blue', 'green', 'orange']
11.
© SkillBrew http://skillbrew.com Remove
an element from list (2) If you try to remove an element which is not there in the list a ValueError is raised 11 >>> colors ['red', 'blue', 'green', 'orange'] >>> colors.remove('yellow') Traceback (most recent call last): File "<pyshell#24>", line 1, in <module> colors.remove('yellow') ValueError: list.remove(x): x not in list
12.
© SkillBrew http://skillbrew.com Delete
an element from list del list[index] Use del operator to delete an element from a list 12 >>> colors ['red', 'blue', 'green', 'orange'] >>> del colors[1] >>> colors ['red', 'green', 'orange']
13.
© SkillBrew http://skillbrew.com Sorting
a list sort()sorts the list in place In place means that sort works on the original list rather than giving back a new list 13 >>> colors ['red', 'green', 'orange'] >>> colors.sort() >>> colors ['green', 'orange', 'red']
14.
© SkillBrew http://skillbrew.com Reverse
a list reverse()reverses the list in place In place means that reverse()works on the original list rather than giving back a new list 14 >>> colors ['green', 'orange', 'red'] >>> colors.reverse() >>> colors ['red', 'orange', 'green']
15.
© SkillBrew http://skillbrew.com Using
list as stack A stack is a list with just two operations: • Push • Pop 15
16.
© SkillBrew http://skillbrew.com Stack
– push 40 30 20 10 16 50 40 30 20 10 stack.append(50) >>> stack = [10, 20, 30, 40] >>> stack.append(50) >>> stack [10, 20, 30, 40, 50]
17.
© SkillBrew http://skillbrew.com Stack
– pop 17 50 40 30 20 10 stack.pop( ) >>> stack [10, 20, 30, 40, 50] >>> stack.pop() 50 >>> stack [10, 20, 30, 40] 40 30 20 10
18.
© SkillBrew http://skillbrew.com List
slicing Slicing: Extracting parts of list Syntax: list[start:end] list[start:] list[end:] list[:] start inclusive and excluding end Slicing returns a new list 18
19.
© SkillBrew http://skillbrew.com List
slicing (2) 19 >>> colors = ['yellow', 'red', 'blue', 'green', 'black'] >>> colors[0:] ['yellow', 'red', 'blue', 'green', 'black'] >>> colors[:4] ['yellow', 'red', 'blue', 'green'] >>> colors[1:3] ['red', 'blue'] >>> colors[:] ['yellow', 'red', 'blue', 'green', 'black']
20.
© SkillBrew http://skillbrew.com Summary
What is a list List creation Access elements of a list Basic List operations Sorting and reversing a list Using list as stack Slicing 20
21.
© SkillBrew http://skillbrew.com Resources
Tutorial on lists http://www.tutorialspoint.com/Python/Python_lists.htm 21
22.
22
Hinweis der Redaktion
Here the intention is to implement a stack using lists
Here we have a stack with 10, 20, 30, 40 already present append is equivalent to a PUSH operation in a stack
Stack after append operation has 50 on top pop will remove 50 from top, just like POP in a stack Data Structure
These have been covered in detail in strings hence just a brief overview of slicing is presented here