SlideShare a Scribd company logo
PART 2
LISTS IN PYTHON
• WANT TO LEARN PYTHON PROGRAMMING? (SUBTITLES)
• SUBSCRIBE
• TELEGRAM – FreeCodeSchool
• Twitter – shivammitra4
• LinkedIn – shivammitra
• Link in description
• INSTALLING PYTHON
• VARIABLES AND DATA TYPES
• PLAYLIST LINK IN DESCRIPTION
STORING MULTIPLE NAMES ?
• 5 names, 10 names …. 100 names
• Storing it in strings doesn’t scale well
• Storing multiple numbers
• Code clarity
• Slow access
INTRODUCING LISTS
• A list is a collection of items in a particular order
• List of
• Names
• Places
• list of digits
• list of colors
• Good to name your list names as plurals – names, places etc
LISTS IN PYTHON
• Use square brackets ([]) to represent a list
• Individuals elements are separated by a comma
• Printing a list
ACCESSING ELEMENTS IN A LIST
• Lists are ordered
• Access an element by its position or index
• In Python and most languages, list numbering starts from 0th position
• This is very important
USE STRING METHODS ON THESE ELEMENTS
REMEMBER THIS IMPORTANT THING
• Each index in a list contains a data type – integers, float, strings etc
• Instead to using multiple variable names, you are using a single
variable name to store all these
• All functions/operations on a data type applies here to elements
CAN WE STORE DIFFERENT DATA TYPES IN A
LIST ?
But mostly we will store same type of data
LENGTH OF THE LIST USING LEN() FUNCTION
ACCESSING LAST ELEMENTS IN A LIST
NEGATIVE INDEXING IN PYTHON
THIS WILL BE FASTER THAN THE LAST METHOD
STRINGS VS LISTS IN PYTHON
MODIFYING AN ELEMENT - LIST VS STRING
MUTABLE VS IMMUTABLE DATA TYPES
• Immutable data type
• The value/data cannot be changed
• Example: strings, integers, floats etc
• Mutable data type
• The value/data can be changed
• Example – lists
• More about this in a separate video
INSERTING ELEMENTS
TO A LIST
INSERTING ELEMENTS AT THE END OF A LIST
• This is very common
• As data is mostly known after the program starts running
INSERTING ELEMENTS AT ANY POSITION
REMOVING ELEMENTS
FROM A LIST
REMOVING USING DEL STATEMENTS
REMOVING USING POP METHOD
• The pop() method removes the last item in a list, but it lets you work
with that item after removing it
POPPING ITEMS FROM ANY POSITION IN THE
LIST
WHEN TO USE DEL VS POP ?
REMOVING AN ELEMENT BY VALUE
REMOVING AN ELEMENT NOT IN A LIST
CAN DUPLICATES BE REMOVED ?
• Removes first matching value
• USING REMOVE AGAIN WILL DO
ORGANIZING A LIST
SORTING A LIST
• Putting the elements in a particular order
• Increasing order
• Decreasing order
• Numbers = [2, 1, 3]
• Increasing = [1, 2, 3]
• Decreasing = [3, 2, 1]
SORTING A LIST OF STRINGS
• Alphabetical order
• Names = [‘Shivam’, ’Anil’, ‘Navneet’]
• Increasing alphabetical order = [‘Anil’, ‘Navneet’, ‘Shivam’]
• Decreasing alphabetical order = [‘Shivam’, ‘Navneet’, ‘Anil’]
SORTING A LIST PERMANENTLY WITH SORT
FUNCTION
BY DEFAULT, SORT() SHORTES IN INCREASING ORDER
SORTING IN REVERSE ALPHABETIC ORDER
SORTING A LIST TEMPORARILY WITH SORTED
FUNCTION
• To maintain the original order of a list but present it in a sorted order,
you can use the sorted() function.
• The sorted() function lets you display your list in a particular order but
doesn’t affect the actual order of the list.
PRINTING A LIST IN REVERSE ORDER
What if you reverse again ?
AVOIDING INDEX ERRORS WHEN WORKING
WITH LIST
REMEMBER THAT INDEXING STARTS AT 0
FOR LOOP IN PYTHON
AND USING LISTS

More Related Content

What's hot (20)

POINTERS IN C
POINTERS IN CPOINTERS IN C
POINTERS IN C
 
Introduction to python 3
Introduction to python 3Introduction to python 3
Introduction to python 3
 
Python variables and data types.pptx
Python variables and data types.pptxPython variables and data types.pptx
Python variables and data types.pptx
 
Variables & Data Types In Python | Edureka
Variables & Data Types In Python | EdurekaVariables & Data Types In Python | Edureka
Variables & Data Types In Python | Edureka
 
Python
PythonPython
Python
 
Python basics
Python basicsPython basics
Python basics
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Python Programming
Python ProgrammingPython Programming
Python Programming
 
Introduction to programming with python
Introduction to programming with pythonIntroduction to programming with python
Introduction to programming with python
 
Pointer in C
Pointer in CPointer in C
Pointer in C
 
Python strings
Python stringsPython strings
Python strings
 
Function in Python
Function in PythonFunction in Python
Function in Python
 
Function Parameters
Function ParametersFunction Parameters
Function Parameters
 
Pointers
PointersPointers
Pointers
 
Python Class | Python Programming | Python Tutorial | Edureka
Python Class | Python Programming | Python Tutorial | EdurekaPython Class | Python Programming | Python Tutorial | Edureka
Python Class | Python Programming | Python Tutorial | Edureka
 
Lesson 03 python statement, indentation and comments
Lesson 03   python statement, indentation and commentsLesson 03   python statement, indentation and comments
Lesson 03 python statement, indentation and comments
 
Pointers in c language
Pointers in c languagePointers in c language
Pointers in c language
 
Variables in python
Variables in pythonVariables in python
Variables in python
 
Python
PythonPython
Python
 
Python by Rj
Python by RjPython by Rj
Python by Rj
 

Similar to Part 2 - Python Tutorial | Introduction to Lists

Python programming
Python programmingPython programming
Python programmingsirikeshava
 
VARIABLES AND DATA TYPES IN PYTHON NEED TO STUDY
VARIABLES AND DATA TYPES IN PYTHON NEED TO STUDYVARIABLES AND DATA TYPES IN PYTHON NEED TO STUDY
VARIABLES AND DATA TYPES IN PYTHON NEED TO STUDYRushikesh Kolhe
 
Stack and queue power point presentation data structure and algorithms Stack-...
Stack and queue power point presentation data structure and algorithms Stack-...Stack and queue power point presentation data structure and algorithms Stack-...
Stack and queue power point presentation data structure and algorithms Stack-...abhaysingh19149
 
Apl – a programming language
Apl – a programming languageApl – a programming language
Apl – a programming languageBryan Wilson
 
Lecture 01 Intro to DSA
Lecture 01 Intro to DSALecture 01 Intro to DSA
Lecture 01 Intro to DSANurjahan Nipa
 
Introduction to lists
Introduction to listsIntroduction to lists
Introduction to listsaiclub_slides
 
Computer Sience, This is my presentation for beginners coding in python
Computer Sience, This is my presentation for beginners coding in pythonComputer Sience, This is my presentation for beginners coding in python
Computer Sience, This is my presentation for beginners coding in pythonalin173596
 
MODULE-2.pptx
MODULE-2.pptxMODULE-2.pptx
MODULE-2.pptxASRPANDEY
 

Similar to Part 2 - Python Tutorial | Introduction to Lists (13)

Python programming
Python programmingPython programming
Python programming
 
Linked List
Linked ListLinked List
Linked List
 
VARIABLES AND DATA TYPES IN PYTHON NEED TO STUDY
VARIABLES AND DATA TYPES IN PYTHON NEED TO STUDYVARIABLES AND DATA TYPES IN PYTHON NEED TO STUDY
VARIABLES AND DATA TYPES IN PYTHON NEED TO STUDY
 
Stack and queue power point presentation data structure and algorithms Stack-...
Stack and queue power point presentation data structure and algorithms Stack-...Stack and queue power point presentation data structure and algorithms Stack-...
Stack and queue power point presentation data structure and algorithms Stack-...
 
Apl – a programming language
Apl – a programming languageApl – a programming language
Apl – a programming language
 
Lecture 01 Intro to DSA
Lecture 01 Intro to DSALecture 01 Intro to DSA
Lecture 01 Intro to DSA
 
Data structures2
Data structures2Data structures2
Data structures2
 
2- link-list.ppt
2- link-list.ppt2- link-list.ppt
2- link-list.ppt
 
Introduction to lists
Introduction to listsIntroduction to lists
Introduction to lists
 
Computer Sience, This is my presentation for beginners coding in python
Computer Sience, This is my presentation for beginners coding in pythonComputer Sience, This is my presentation for beginners coding in python
Computer Sience, This is my presentation for beginners coding in python
 
MODULE-2.pptx
MODULE-2.pptxMODULE-2.pptx
MODULE-2.pptx
 
Python
PythonPython
Python
 
ds bridge.pptx
ds bridge.pptxds bridge.pptx
ds bridge.pptx
 

More from Shivam Mitra

Preparing for SRE Interviews
Preparing for SRE InterviewsPreparing for SRE Interviews
Preparing for SRE InterviewsShivam Mitra
 
PART 8 - Python Tutorial | User Input In Python With Examples
PART 8 - Python Tutorial | User Input In Python With ExamplesPART 8 - Python Tutorial | User Input In Python With Examples
PART 8 - Python Tutorial | User Input In Python With ExamplesShivam Mitra
 
PART 6 - Python Tutorial | Tuples In Python With Examples
PART 6 - Python Tutorial | Tuples In Python With ExamplesPART 6 - Python Tutorial | Tuples In Python With Examples
PART 6 - Python Tutorial | Tuples In Python With ExamplesShivam Mitra
 
PART 0 - Python Tutorial | Why should you learn python
PART 0 - Python Tutorial | Why should you learn pythonPART 0 - Python Tutorial | Why should you learn python
PART 0 - Python Tutorial | Why should you learn pythonShivam Mitra
 
Memory management in operating system | Paging | Virtual memory
Memory management in operating system | Paging | Virtual memoryMemory management in operating system | Paging | Virtual memory
Memory management in operating system | Paging | Virtual memoryShivam Mitra
 
Process Synchronization in operating system | mutex | semaphore | race condition
Process Synchronization in operating system | mutex | semaphore | race conditionProcess Synchronization in operating system | mutex | semaphore | race condition
Process Synchronization in operating system | mutex | semaphore | race conditionShivam Mitra
 
Process Scheduling Algorithms | Interviews | Operating system
Process Scheduling Algorithms | Interviews | Operating systemProcess Scheduling Algorithms | Interviews | Operating system
Process Scheduling Algorithms | Interviews | Operating systemShivam Mitra
 
Threads in Operating System | Multithreading | Interprocess Communication
Threads in Operating System | Multithreading | Interprocess CommunicationThreads in Operating System | Multithreading | Interprocess Communication
Threads in Operating System | Multithreading | Interprocess CommunicationShivam Mitra
 
Process management in operating system | process states | PCB | FORK() | Zomb...
Process management in operating system | process states | PCB | FORK() | Zomb...Process management in operating system | process states | PCB | FORK() | Zomb...
Process management in operating system | process states | PCB | FORK() | Zomb...Shivam Mitra
 
Introduction to operating system, system calls and interrupts
Introduction to operating system, system calls and interruptsIntroduction to operating system, system calls and interrupts
Introduction to operating system, system calls and interruptsShivam Mitra
 
What is Internet and How it Works
What is Internet and How it WorksWhat is Internet and How it Works
What is Internet and How it WorksShivam Mitra
 
OSI Model Layers and Internet Protocol Stack
OSI Model Layers and Internet Protocol StackOSI Model Layers and Internet Protocol Stack
OSI Model Layers and Internet Protocol StackShivam Mitra
 
Basics of Stock Market
Basics of Stock MarketBasics of Stock Market
Basics of Stock MarketShivam Mitra
 
Assets vs liability
Assets vs liabilityAssets vs liability
Assets vs liabilityShivam Mitra
 
Pycricbuzz - a python library to fetch live cricket scores
Pycricbuzz -  a python library to fetch live cricket scoresPycricbuzz -  a python library to fetch live cricket scores
Pycricbuzz - a python library to fetch live cricket scoresShivam Mitra
 

More from Shivam Mitra (15)

Preparing for SRE Interviews
Preparing for SRE InterviewsPreparing for SRE Interviews
Preparing for SRE Interviews
 
PART 8 - Python Tutorial | User Input In Python With Examples
PART 8 - Python Tutorial | User Input In Python With ExamplesPART 8 - Python Tutorial | User Input In Python With Examples
PART 8 - Python Tutorial | User Input In Python With Examples
 
PART 6 - Python Tutorial | Tuples In Python With Examples
PART 6 - Python Tutorial | Tuples In Python With ExamplesPART 6 - Python Tutorial | Tuples In Python With Examples
PART 6 - Python Tutorial | Tuples In Python With Examples
 
PART 0 - Python Tutorial | Why should you learn python
PART 0 - Python Tutorial | Why should you learn pythonPART 0 - Python Tutorial | Why should you learn python
PART 0 - Python Tutorial | Why should you learn python
 
Memory management in operating system | Paging | Virtual memory
Memory management in operating system | Paging | Virtual memoryMemory management in operating system | Paging | Virtual memory
Memory management in operating system | Paging | Virtual memory
 
Process Synchronization in operating system | mutex | semaphore | race condition
Process Synchronization in operating system | mutex | semaphore | race conditionProcess Synchronization in operating system | mutex | semaphore | race condition
Process Synchronization in operating system | mutex | semaphore | race condition
 
Process Scheduling Algorithms | Interviews | Operating system
Process Scheduling Algorithms | Interviews | Operating systemProcess Scheduling Algorithms | Interviews | Operating system
Process Scheduling Algorithms | Interviews | Operating system
 
Threads in Operating System | Multithreading | Interprocess Communication
Threads in Operating System | Multithreading | Interprocess CommunicationThreads in Operating System | Multithreading | Interprocess Communication
Threads in Operating System | Multithreading | Interprocess Communication
 
Process management in operating system | process states | PCB | FORK() | Zomb...
Process management in operating system | process states | PCB | FORK() | Zomb...Process management in operating system | process states | PCB | FORK() | Zomb...
Process management in operating system | process states | PCB | FORK() | Zomb...
 
Introduction to operating system, system calls and interrupts
Introduction to operating system, system calls and interruptsIntroduction to operating system, system calls and interrupts
Introduction to operating system, system calls and interrupts
 
What is Internet and How it Works
What is Internet and How it WorksWhat is Internet and How it Works
What is Internet and How it Works
 
OSI Model Layers and Internet Protocol Stack
OSI Model Layers and Internet Protocol StackOSI Model Layers and Internet Protocol Stack
OSI Model Layers and Internet Protocol Stack
 
Basics of Stock Market
Basics of Stock MarketBasics of Stock Market
Basics of Stock Market
 
Assets vs liability
Assets vs liabilityAssets vs liability
Assets vs liability
 
Pycricbuzz - a python library to fetch live cricket scores
Pycricbuzz -  a python library to fetch live cricket scoresPycricbuzz -  a python library to fetch live cricket scores
Pycricbuzz - a python library to fetch live cricket scores
 

Recently uploaded

Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxEduSkills OECD
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismDeeptiGupta154
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfSpecial education needs
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)rosedainty
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPCeline George
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxbennyroshan06
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonSteve Thomason
 
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptxJose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptxricssacare
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfThiyagu K
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxRaedMohamed3
 
Extraction Of Natural Dye From Beetroot (Beta Vulgaris) And Preparation Of He...
Extraction Of Natural Dye From Beetroot (Beta Vulgaris) And Preparation Of He...Extraction Of Natural Dye From Beetroot (Beta Vulgaris) And Preparation Of He...
Extraction Of Natural Dye From Beetroot (Beta Vulgaris) And Preparation Of He...SachinKumar945617
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationDelapenabediema
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxJheel Barad
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleCeline George
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chipsGeoBlogs
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...AzmatAli747758
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXMIRIAMSALINAS13
 
Solid waste management & Types of Basic civil Engineering notes by DJ Sir.pptx
Solid waste management & Types of Basic civil Engineering notes by DJ Sir.pptxSolid waste management & Types of Basic civil Engineering notes by DJ Sir.pptx
Solid waste management & Types of Basic civil Engineering notes by DJ Sir.pptxDenish Jangid
 
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...Nguyen Thanh Tu Collection
 

Recently uploaded (20)

Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
 
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptxJose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
Extraction Of Natural Dye From Beetroot (Beta Vulgaris) And Preparation Of He...
Extraction Of Natural Dye From Beetroot (Beta Vulgaris) And Preparation Of He...Extraction Of Natural Dye From Beetroot (Beta Vulgaris) And Preparation Of He...
Extraction Of Natural Dye From Beetroot (Beta Vulgaris) And Preparation Of He...
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
Solid waste management & Types of Basic civil Engineering notes by DJ Sir.pptx
Solid waste management & Types of Basic civil Engineering notes by DJ Sir.pptxSolid waste management & Types of Basic civil Engineering notes by DJ Sir.pptx
Solid waste management & Types of Basic civil Engineering notes by DJ Sir.pptx
 
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
50 ĐỀ LUYỆN THI IOE LỚP 9 - NĂM HỌC 2022-2023 (CÓ LINK HÌNH, FILE AUDIO VÀ ĐÁ...
 

Part 2 - Python Tutorial | Introduction to Lists

  • 1. PART 2 LISTS IN PYTHON • WANT TO LEARN PYTHON PROGRAMMING? (SUBTITLES) • SUBSCRIBE • TELEGRAM – FreeCodeSchool • Twitter – shivammitra4 • LinkedIn – shivammitra • Link in description • INSTALLING PYTHON • VARIABLES AND DATA TYPES • PLAYLIST LINK IN DESCRIPTION
  • 2. STORING MULTIPLE NAMES ? • 5 names, 10 names …. 100 names • Storing it in strings doesn’t scale well • Storing multiple numbers • Code clarity • Slow access
  • 3. INTRODUCING LISTS • A list is a collection of items in a particular order • List of • Names • Places • list of digits • list of colors • Good to name your list names as plurals – names, places etc
  • 4. LISTS IN PYTHON • Use square brackets ([]) to represent a list • Individuals elements are separated by a comma • Printing a list
  • 5. ACCESSING ELEMENTS IN A LIST • Lists are ordered • Access an element by its position or index • In Python and most languages, list numbering starts from 0th position • This is very important
  • 6. USE STRING METHODS ON THESE ELEMENTS
  • 7. REMEMBER THIS IMPORTANT THING • Each index in a list contains a data type – integers, float, strings etc • Instead to using multiple variable names, you are using a single variable name to store all these • All functions/operations on a data type applies here to elements
  • 8. CAN WE STORE DIFFERENT DATA TYPES IN A LIST ? But mostly we will store same type of data
  • 9. LENGTH OF THE LIST USING LEN() FUNCTION
  • 11. NEGATIVE INDEXING IN PYTHON THIS WILL BE FASTER THAN THE LAST METHOD
  • 12. STRINGS VS LISTS IN PYTHON
  • 13. MODIFYING AN ELEMENT - LIST VS STRING
  • 14. MUTABLE VS IMMUTABLE DATA TYPES • Immutable data type • The value/data cannot be changed • Example: strings, integers, floats etc • Mutable data type • The value/data can be changed • Example – lists • More about this in a separate video
  • 16. INSERTING ELEMENTS AT THE END OF A LIST
  • 17. • This is very common • As data is mostly known after the program starts running
  • 18. INSERTING ELEMENTS AT ANY POSITION
  • 19.
  • 21. REMOVING USING DEL STATEMENTS
  • 22. REMOVING USING POP METHOD • The pop() method removes the last item in a list, but it lets you work with that item after removing it
  • 23. POPPING ITEMS FROM ANY POSITION IN THE LIST
  • 24. WHEN TO USE DEL VS POP ?
  • 26. REMOVING AN ELEMENT NOT IN A LIST
  • 27. CAN DUPLICATES BE REMOVED ? • Removes first matching value • USING REMOVE AGAIN WILL DO
  • 29. SORTING A LIST • Putting the elements in a particular order • Increasing order • Decreasing order • Numbers = [2, 1, 3] • Increasing = [1, 2, 3] • Decreasing = [3, 2, 1]
  • 30. SORTING A LIST OF STRINGS • Alphabetical order • Names = [‘Shivam’, ’Anil’, ‘Navneet’] • Increasing alphabetical order = [‘Anil’, ‘Navneet’, ‘Shivam’] • Decreasing alphabetical order = [‘Shivam’, ‘Navneet’, ‘Anil’]
  • 31. SORTING A LIST PERMANENTLY WITH SORT FUNCTION BY DEFAULT, SORT() SHORTES IN INCREASING ORDER
  • 32. SORTING IN REVERSE ALPHABETIC ORDER
  • 33.
  • 34. SORTING A LIST TEMPORARILY WITH SORTED FUNCTION • To maintain the original order of a list but present it in a sorted order, you can use the sorted() function. • The sorted() function lets you display your list in a particular order but doesn’t affect the actual order of the list.
  • 35.
  • 36. PRINTING A LIST IN REVERSE ORDER What if you reverse again ?
  • 37. AVOIDING INDEX ERRORS WHEN WORKING WITH LIST REMEMBER THAT INDEXING STARTS AT 0
  • 38.
  • 39. FOR LOOP IN PYTHON AND USING LISTS