Python Tutorial
Python tutorial for beginners
Learn Python Programming
Python3 Tutorial
Python programming tutorial
Python youtube tutorial
Python online tutorial
Best Python Tutorial on Youtube
Jobs for python programmers
stackoverflow survey
Best Python tutorial
Best Python course
Python full course
Python job interview
Python job for fresher
Python job salary in India
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
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
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
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
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
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 ?