SlideShare a Scribd company logo
5
List
Creating list using range()
Example #Create list
num = list(range(4, 9, 2))
print(num)
Most read
21
Tuple
Basic Operations On Tuples
s = (10, "Ram", 10, 20, 30, 40, 50)
To find the length of the tuple
print(len(s))
Repetition operator
fee = (25.000, ) * 4
print(fee)
Concatenate the tuples using *
ns = s + fee
print(ns)
Membership
name = "Ram"
print(name in s)
Repetition
t1 = (1, 2, 3)
t2 = t1 * 3
print(t2)
Most read
22
Tuple
Functions To Process Tuples
len() len(tpl) Returns the number of elements in the tuple
min() min(tpl) Returns the smallest element in the tuple
max() max() Returns the biggest element in the tuple
count() tpl.count(x) Returns how many times the element ‘x’ is found in the tuple
index() tpl.index(x) Returns the first occurrence of the element ‘x’ in tpl.
Raises ValueError if ‘x’ is not found in the tuple
sorted() sorted(tpl) Sorts the elements of the tuple into ascending order.
sorted(tpl, reverse=True) will sort in reverse order
Most read
List And Tuples
Team Emertxe
List
List
Introduction

Used for storing different types of data unlike arrays
Example-1 student = [10, "Amar", 'M', 50, 55, 57, 67, 47]
Example-2 e_list = [] #Empty List

Indexing + Slicing can be applied on list
Example-1 print(student[1]) Gives "Amar"
Example-2 print(student[0: 3: 1])
Prints [10, "Amar", 'M']
Example-3 student[::] Print all elements
List
Examples
Example-1 #Create list with integer numbers
num = [10, 20, 30, 40, 50]
print(num)
print("num[0]: %dtnum[2]: %dn" % (num[0], num[2]))
Example-2 #Create list with strings
names = ["Ram", "Amar", "Thomas"]
print(names)
print("names[0]: %stnames[2]: %sn" % (names[0], names[2]))
Example-3 #Create list with different dtypes
x = [10, 20, 1.5, 6.7, "Ram", 'M']
print(x)
print("x[0]: %dtx[2]: %ftx[4]: %stx[5]: %cn" %(x[0], x[2], x[4], x[5]))
List
Creating list using range()
Example #Create list
num = list(range(4, 9, 2))
print(num)
List
Updating list
1 Creation lst = list(range(1, 5))
print(lst)
[1, 2, 3, 4]
2 append lst.append(9)
print(lst)
[1, 2, 3, 4, 9]
3 Update-1 lst[1] = 8
print(lst)
[1, 8, 3, 4, 9]
4 Update-2 lst[1: 3] = 10, 11
print(lst)
[1, 10, 11, 4, 9]
5 delete del lst[1]
print(lst)
[1, 11, 4, 9]
6 remove lst.remove(11)
print(lst)
[1, 4, 9]
7 reverse lst.reverse()
print(lst)
[9, 4, 1]
List
Concatenation of Two List
'+' operator is used to join two list
Example x = [10, 20, 30]
y = [5, 6, 7]
print(x + y)
List
Repetition of List
'*' is used to repeat the list 'n' times
Example x = [10, 20, 30]
print(x * 2)
List
Membership of List
'in' and 'not in' operators are used to check, whether an element belongs to the list
or not
Example x = [1, 2, 3, 4, 5]
a = 3
print(a in x)
Returns True, if the item is found
in the list
Example x = [1, 2, 3, 4, 5]
a = 7
print(a not in x)
Returns True, if the item is not
found in the list
List
Aliasing And Cloning Lists
Aliasing: Giving new name for the existing list
Example x = [10, 20, 30, 40]
y = x
Note: No separate memory will be allocated for y
Cloning / Copy: Making a copy
Example x = [10, 20, 30, 40]
y = x[:] <=> y = x.copy()
x[1] = 99
print(x)
print(y)
Note: Changes made in one list will not reflect other
List
Exercise
1. To find the maximum & minimum item in a list of items
2. Implement Bubble sort
3. To know how many times an element occurred in the list
4. To create employee list and search for the particular employee
List
To find the common items
#To find the common item in two lists
l1 = ["Thomas", "Richard", "Purdie", "Chris"]
l2 = ["Ram", "Amar", "Anthony", "Richard"]
#Covert them into sets
s1 = set(l1)
s2 = set(l2)
#Filter intersection of two sets
s3 = s1.intersection(s2)
#Convert back into the list
common = list(s3)
print(common)
List
Nested List
#To create a list with another list as element
list = [10, 20, 30, [80, 90]]
print(list)
List
List Comprehensions
Example-1: Create a list with squares of integers from 1 to 10
#Version-1
squares = []
for x in range(1, 11):
squares.append(x ** 2)
print(squares)
#Version-2
squares = []
squares = [x ** 2 for x in range(1, 11)]
print(squares)

List comprehensions represent creation of new lists from an iterable object(list, set,

tuple, dictionary or range) that satisfies a given condition
List
List Comprehensions
Example-2: Get squares of integers from 1 to 10 and take only the even numbers from the
result
even_squares = [x ** 2 for x in range(1, 11) if x % 2 == 0]
print(even_squares)

List comprehensions represent creation of new lists from an iterable object(list, set,

tuple, dictionary or range) that satisfies a given condition
List
List Comprehensions
Example-3: #Adding the elements of two list one by one
#Example-1
x = [10, 20, 30]
y = [1, 2, 3, 4]
lst = []
#Version-1
for i in x:
for j in y:
lst.append(i + j)
#Version-2
lst = [i + j for i in x for j in y]
#Example-2
lst = [i + j for i in "ABC" for j in "DE"]
print(lst)

List comprehensions represent creation of new lists from an iterable object(list, set,

tuple, dictionary or range) that satisfies a given condition
Tuple
Tuple
Introduction

A tuple is similar to list but it is immutable
Tuple
Creating Tuples
To create empty tuple
tup1 = ()
Tuple with one item
tup1 = (10, )
Tuple with different dtypes
tup3 = (10, 20, 1.1, 2.3, "Ram", 'M')
Tuple with no braces
t4 = 10, 20, 30, 40
Create tuple from the list
list = [10, 1.2, "Ram", 'M']
t5 = tuple(list)
Create tuple from range
t6 = tuple(range(4, 10, 2))
Tuple
Accessing Tuples

Accessing items in the tuple can be done by indexing or slicing method, similar to
that of list
Tuple
Basic Operations On Tuples
s = (10, "Ram", 10, 20, 30, 40, 50)
To find the length of the tuple
print(len(s))
Repetition operator
fee = (25.000, ) * 4
print(fee)
Concatenate the tuples using *
ns = s + fee
print(ns)
Membership
name = "Ram"
print(name in s)
Repetition
t1 = (1, 2, 3)
t2 = t1 * 3
print(t2)
Tuple
Functions To Process Tuples
len() len(tpl) Returns the number of elements in the tuple
min() min(tpl) Returns the smallest element in the tuple
max() max() Returns the biggest element in the tuple
count() tpl.count(x) Returns how many times the element ‘x’ is found in the tuple
index() tpl.index(x) Returns the first occurrence of the element ‘x’ in tpl.
Raises ValueError if ‘x’ is not found in the tuple
sorted() sorted(tpl) Sorts the elements of the tuple into ascending order.
sorted(tpl, reverse=True) will sort in reverse order
Tuple
Exercise
1. To accept elements in the form of a a tuple and display thier sum and average
2. To find the first occurrence of an element in a tuple
3. To sort a tuple with nested tuples
4. To insert a new item into a tuple at a specified location
5. To modify or replace an existing item of a tuple with new item
6. To delete an element from a particular position in the tuple
THANK YOU

More Related Content

What's hot (20)

Linked list
Linked listLinked list
Linked list
akshat360
 
Introduction to Python
Introduction to Python  Introduction to Python
Introduction to Python
Mohammed Sikander
 
Python Variable Types, List, Tuple, Dictionary
Python Variable Types, List, Tuple, DictionaryPython Variable Types, List, Tuple, Dictionary
Python Variable Types, List, Tuple, Dictionary
Soba Arjun
 
Introduction to NumPy
Introduction to NumPyIntroduction to NumPy
Introduction to NumPy
Huy Nguyen
 
Data types in python
Data types in pythonData types in python
Data types in python
RaginiJain21
 
NumPy
NumPyNumPy
NumPy
AbhijeetAnand88
 
Dictionaries in Python
Dictionaries in PythonDictionaries in Python
Dictionaries in Python
baabtra.com - No. 1 supplier of quality freshers
 
Strings in python
Strings in pythonStrings in python
Strings in python
Prabhakaran V M
 
Bubble sort
Bubble sortBubble sort
Bubble sort
Manek Ar
 
Circular link list.ppt
Circular link list.pptCircular link list.ppt
Circular link list.ppt
Tirthika Bandi
 
Python Data Structures and Algorithms.pptx
Python Data Structures and Algorithms.pptxPython Data Structures and Algorithms.pptx
Python Data Structures and Algorithms.pptx
ShreyasLawand
 
stack & queue
stack & queuestack & queue
stack & queue
manju rani
 
Arrays In Python | Python Array Operations | Edureka
Arrays In Python | Python Array Operations | EdurekaArrays In Python | Python Array Operations | Edureka
Arrays In Python | Python Array Operations | Edureka
Edureka!
 
Python Dictionaries and Sets
Python Dictionaries and SetsPython Dictionaries and Sets
Python Dictionaries and Sets
Nicole Ryan
 
Python list
Python listPython list
Python list
ArchanaBhumkar
 
Arrays in python
Arrays in pythonArrays in python
Arrays in python
moazamali28
 
Ppt bubble sort
Ppt bubble sortPpt bubble sort
Ppt bubble sort
prabhakar jalasutram
 
Datastructures in python
Datastructures in pythonDatastructures in python
Datastructures in python
hydpy
 
Conditional and control statement
Conditional and control statementConditional and control statement
Conditional and control statement
narmadhakin
 
Python Pandas
Python PandasPython Pandas
Python Pandas
Sunil OS
 
Python Variable Types, List, Tuple, Dictionary
Python Variable Types, List, Tuple, DictionaryPython Variable Types, List, Tuple, Dictionary
Python Variable Types, List, Tuple, Dictionary
Soba Arjun
 
Introduction to NumPy
Introduction to NumPyIntroduction to NumPy
Introduction to NumPy
Huy Nguyen
 
Data types in python
Data types in pythonData types in python
Data types in python
RaginiJain21
 
Bubble sort
Bubble sortBubble sort
Bubble sort
Manek Ar
 
Circular link list.ppt
Circular link list.pptCircular link list.ppt
Circular link list.ppt
Tirthika Bandi
 
Python Data Structures and Algorithms.pptx
Python Data Structures and Algorithms.pptxPython Data Structures and Algorithms.pptx
Python Data Structures and Algorithms.pptx
ShreyasLawand
 
Arrays In Python | Python Array Operations | Edureka
Arrays In Python | Python Array Operations | EdurekaArrays In Python | Python Array Operations | Edureka
Arrays In Python | Python Array Operations | Edureka
Edureka!
 
Python Dictionaries and Sets
Python Dictionaries and SetsPython Dictionaries and Sets
Python Dictionaries and Sets
Nicole Ryan
 
Arrays in python
Arrays in pythonArrays in python
Arrays in python
moazamali28
 
Datastructures in python
Datastructures in pythonDatastructures in python
Datastructures in python
hydpy
 
Conditional and control statement
Conditional and control statementConditional and control statement
Conditional and control statement
narmadhakin
 
Python Pandas
Python PandasPython Pandas
Python Pandas
Sunil OS
 

Similar to Python programming : List and tuples (20)

List_tuple_dictionary.pptx
List_tuple_dictionary.pptxList_tuple_dictionary.pptx
List_tuple_dictionary.pptx
ChandanVatsa2
 
python_avw - Unit-03.pdf
python_avw - Unit-03.pdfpython_avw - Unit-03.pdf
python_avw - Unit-03.pdf
AshaWankar1
 
The Ring programming language version 1.9 book - Part 29 of 210
The Ring programming language version 1.9 book - Part 29 of 210The Ring programming language version 1.9 book - Part 29 of 210
The Ring programming language version 1.9 book - Part 29 of 210
Mahmoud Samir Fayed
 
The Ring programming language version 1.8 book - Part 27 of 202
The Ring programming language version 1.8 book - Part 27 of 202The Ring programming language version 1.8 book - Part 27 of 202
The Ring programming language version 1.8 book - Part 27 of 202
Mahmoud Samir Fayed
 
Module-2.pptx
Module-2.pptxModule-2.pptx
Module-2.pptx
GaganRaj28
 
The Ring programming language version 1.7 book - Part 26 of 196
The Ring programming language version 1.7 book - Part 26 of 196The Ring programming language version 1.7 book - Part 26 of 196
The Ring programming language version 1.7 book - Part 26 of 196
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 30 of 212
The Ring programming language version 1.10 book - Part 30 of 212The Ring programming language version 1.10 book - Part 30 of 212
The Ring programming language version 1.10 book - Part 30 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.3 book - Part 22 of 184
The Ring programming language version 1.5.3 book - Part 22 of 184The Ring programming language version 1.5.3 book - Part 22 of 184
The Ring programming language version 1.5.3 book - Part 22 of 184
Mahmoud Samir Fayed
 
Pytho_tuples
Pytho_tuplesPytho_tuples
Pytho_tuples
BMS Institute of Technology and Management
 
Lists.pptx
Lists.pptxLists.pptx
Lists.pptx
Yagna15
 
GE3151 PSPP UNIT IV QUESTION BANK.docx.pdf
GE3151 PSPP UNIT IV QUESTION BANK.docx.pdfGE3151 PSPP UNIT IV QUESTION BANK.docx.pdf
GE3151 PSPP UNIT IV QUESTION BANK.docx.pdf
Guru Nanak Technical Institutions
 
The Ring programming language version 1.2 book - Part 12 of 84
The Ring programming language version 1.2 book - Part 12 of 84The Ring programming language version 1.2 book - Part 12 of 84
The Ring programming language version 1.2 book - Part 12 of 84
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.1 book - Part 21 of 180
The Ring programming language version 1.5.1 book - Part 21 of 180The Ring programming language version 1.5.1 book - Part 21 of 180
The Ring programming language version 1.5.1 book - Part 21 of 180
Mahmoud Samir Fayed
 
Unit 4.pptx python list tuples dictionary
Unit 4.pptx python list tuples dictionaryUnit 4.pptx python list tuples dictionary
Unit 4.pptx python list tuples dictionary
shakthi10
 
Practice_Exercises_Data_Structures.pptx
Practice_Exercises_Data_Structures.pptxPractice_Exercises_Data_Structures.pptx
Practice_Exercises_Data_Structures.pptx
Rahul Borate
 
Python list tuple dictionary .pptx
Python list tuple dictionary       .pptxPython list tuple dictionary       .pptx
Python list tuple dictionary .pptx
miteshchaudhari4466
 
The Ring programming language version 1.6 book - Part 24 of 189
The Ring programming language version 1.6 book - Part 24 of 189The Ring programming language version 1.6 book - Part 24 of 189
The Ring programming language version 1.6 book - Part 24 of 189
Mahmoud Samir Fayed
 
Write a function called countElements that counts the number of times.pdf
Write a function called countElements that counts the number of times.pdfWrite a function called countElements that counts the number of times.pdf
Write a function called countElements that counts the number of times.pdf
feetshoemart
 
Python Lecture 8
Python Lecture 8Python Lecture 8
Python Lecture 8
Inzamam Baig
 
STRING LIST TUPLE DICTIONARY FILE.pdf
STRING LIST TUPLE DICTIONARY FILE.pdfSTRING LIST TUPLE DICTIONARY FILE.pdf
STRING LIST TUPLE DICTIONARY FILE.pdf
omprakashmeena48
 
List_tuple_dictionary.pptx
List_tuple_dictionary.pptxList_tuple_dictionary.pptx
List_tuple_dictionary.pptx
ChandanVatsa2
 
python_avw - Unit-03.pdf
python_avw - Unit-03.pdfpython_avw - Unit-03.pdf
python_avw - Unit-03.pdf
AshaWankar1
 
The Ring programming language version 1.9 book - Part 29 of 210
The Ring programming language version 1.9 book - Part 29 of 210The Ring programming language version 1.9 book - Part 29 of 210
The Ring programming language version 1.9 book - Part 29 of 210
Mahmoud Samir Fayed
 
The Ring programming language version 1.8 book - Part 27 of 202
The Ring programming language version 1.8 book - Part 27 of 202The Ring programming language version 1.8 book - Part 27 of 202
The Ring programming language version 1.8 book - Part 27 of 202
Mahmoud Samir Fayed
 
The Ring programming language version 1.7 book - Part 26 of 196
The Ring programming language version 1.7 book - Part 26 of 196The Ring programming language version 1.7 book - Part 26 of 196
The Ring programming language version 1.7 book - Part 26 of 196
Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 30 of 212
The Ring programming language version 1.10 book - Part 30 of 212The Ring programming language version 1.10 book - Part 30 of 212
The Ring programming language version 1.10 book - Part 30 of 212
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.3 book - Part 22 of 184
The Ring programming language version 1.5.3 book - Part 22 of 184The Ring programming language version 1.5.3 book - Part 22 of 184
The Ring programming language version 1.5.3 book - Part 22 of 184
Mahmoud Samir Fayed
 
Lists.pptx
Lists.pptxLists.pptx
Lists.pptx
Yagna15
 
The Ring programming language version 1.2 book - Part 12 of 84
The Ring programming language version 1.2 book - Part 12 of 84The Ring programming language version 1.2 book - Part 12 of 84
The Ring programming language version 1.2 book - Part 12 of 84
Mahmoud Samir Fayed
 
The Ring programming language version 1.5.1 book - Part 21 of 180
The Ring programming language version 1.5.1 book - Part 21 of 180The Ring programming language version 1.5.1 book - Part 21 of 180
The Ring programming language version 1.5.1 book - Part 21 of 180
Mahmoud Samir Fayed
 
Unit 4.pptx python list tuples dictionary
Unit 4.pptx python list tuples dictionaryUnit 4.pptx python list tuples dictionary
Unit 4.pptx python list tuples dictionary
shakthi10
 
Practice_Exercises_Data_Structures.pptx
Practice_Exercises_Data_Structures.pptxPractice_Exercises_Data_Structures.pptx
Practice_Exercises_Data_Structures.pptx
Rahul Borate
 
Python list tuple dictionary .pptx
Python list tuple dictionary       .pptxPython list tuple dictionary       .pptx
Python list tuple dictionary .pptx
miteshchaudhari4466
 
The Ring programming language version 1.6 book - Part 24 of 189
The Ring programming language version 1.6 book - Part 24 of 189The Ring programming language version 1.6 book - Part 24 of 189
The Ring programming language version 1.6 book - Part 24 of 189
Mahmoud Samir Fayed
 
Write a function called countElements that counts the number of times.pdf
Write a function called countElements that counts the number of times.pdfWrite a function called countElements that counts the number of times.pdf
Write a function called countElements that counts the number of times.pdf
feetshoemart
 
STRING LIST TUPLE DICTIONARY FILE.pdf
STRING LIST TUPLE DICTIONARY FILE.pdfSTRING LIST TUPLE DICTIONARY FILE.pdf
STRING LIST TUPLE DICTIONARY FILE.pdf
omprakashmeena48
 
Ad

More from Emertxe Information Technologies Pvt Ltd (20)

Career Transition (1).pdf
Career Transition (1).pdfCareer Transition (1).pdf
Career Transition (1).pdf
Emertxe Information Technologies Pvt Ltd
 
10_isxdigit.pdf
10_isxdigit.pdf10_isxdigit.pdf
10_isxdigit.pdf
Emertxe Information Technologies Pvt Ltd
 
01_student_record.pdf
01_student_record.pdf01_student_record.pdf
01_student_record.pdf
Emertxe Information Technologies Pvt Ltd
 
02_swap.pdf
02_swap.pdf02_swap.pdf
02_swap.pdf
Emertxe Information Technologies Pvt Ltd
 
01_sizeof.pdf
01_sizeof.pdf01_sizeof.pdf
01_sizeof.pdf
Emertxe Information Technologies Pvt Ltd
 
07_product_matrix.pdf
07_product_matrix.pdf07_product_matrix.pdf
07_product_matrix.pdf
Emertxe Information Technologies Pvt Ltd
 
06_sort_names.pdf
06_sort_names.pdf06_sort_names.pdf
06_sort_names.pdf
Emertxe Information Technologies Pvt Ltd
 
05_fragments.pdf
05_fragments.pdf05_fragments.pdf
05_fragments.pdf
Emertxe Information Technologies Pvt Ltd
 
04_magic_square.pdf
04_magic_square.pdf04_magic_square.pdf
04_magic_square.pdf
Emertxe Information Technologies Pvt Ltd
 
03_endianess.pdf
03_endianess.pdf03_endianess.pdf
03_endianess.pdf
Emertxe Information Technologies Pvt Ltd
 
02_variance.pdf
02_variance.pdf02_variance.pdf
02_variance.pdf
Emertxe Information Technologies Pvt Ltd
 
01_memory_manager.pdf
01_memory_manager.pdf01_memory_manager.pdf
01_memory_manager.pdf
Emertxe Information Technologies Pvt Ltd
 
09_nrps.pdf
09_nrps.pdf09_nrps.pdf
09_nrps.pdf
Emertxe Information Technologies Pvt Ltd
 
11_pangram.pdf
11_pangram.pdf11_pangram.pdf
11_pangram.pdf
Emertxe Information Technologies Pvt Ltd
 
10_combinations.pdf
10_combinations.pdf10_combinations.pdf
10_combinations.pdf
Emertxe Information Technologies Pvt Ltd
 
08_squeeze.pdf
08_squeeze.pdf08_squeeze.pdf
08_squeeze.pdf
Emertxe Information Technologies Pvt Ltd
 
07_strtok.pdf
07_strtok.pdf07_strtok.pdf
07_strtok.pdf
Emertxe Information Technologies Pvt Ltd
 
06_reverserec.pdf
06_reverserec.pdf06_reverserec.pdf
06_reverserec.pdf
Emertxe Information Technologies Pvt Ltd
 
05_reverseiter.pdf
05_reverseiter.pdf05_reverseiter.pdf
05_reverseiter.pdf
Emertxe Information Technologies Pvt Ltd
 
Ad

Recently uploaded (20)

“How Qualcomm Is Powering AI-driven Multimedia at the Edge,” a Presentation f...
“How Qualcomm Is Powering AI-driven Multimedia at the Edge,” a Presentation f...“How Qualcomm Is Powering AI-driven Multimedia at the Edge,” a Presentation f...
“How Qualcomm Is Powering AI-driven Multimedia at the Edge,” a Presentation f...
Edge AI and Vision Alliance
 
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
angelo60207
 
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdfBoosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Alkin Tezuysal
 
How to Detect Outliers in IBM SPSS Statistics.pptx
How to Detect Outliers in IBM SPSS Statistics.pptxHow to Detect Outliers in IBM SPSS Statistics.pptx
How to Detect Outliers in IBM SPSS Statistics.pptx
Version 1 Analytics
 
If You Use Databricks, You Definitely Need FME
If You Use Databricks, You Definitely Need FMEIf You Use Databricks, You Definitely Need FME
If You Use Databricks, You Definitely Need FME
Safe Software
 
FCF- Getting Started in Cybersecurity 3.0
FCF- Getting Started in Cybersecurity 3.0FCF- Getting Started in Cybersecurity 3.0
FCF- Getting Started in Cybersecurity 3.0
RodrigoMori7
 
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdfcnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
AmirStern2
 
TimeSeries Machine Learning - PyData London 2025
TimeSeries Machine Learning - PyData London 2025TimeSeries Machine Learning - PyData London 2025
TimeSeries Machine Learning - PyData London 2025
Suyash Joshi
 
6th Power Grid Model Meetup - 21 May 2025
6th Power Grid Model Meetup - 21 May 20256th Power Grid Model Meetup - 21 May 2025
6th Power Grid Model Meetup - 21 May 2025
DanBrown980551
 
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc Webinar - 2025 Global Privacy SurveyTrustArc Webinar - 2025 Global Privacy Survey
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc
 
Oracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI FoundationsOracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI Foundations
VICTOR MAESTRE RAMIREZ
 
Soulmaite review - Find Real AI soulmate review
Soulmaite review - Find Real AI soulmate reviewSoulmaite review - Find Real AI soulmate review
Soulmaite review - Find Real AI soulmate review
Soulmaite
 
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
Edge AI and Vision Alliance
 
Developing Schemas with FME and Excel - Peak of Data & AI 2025
Developing Schemas with FME and Excel - Peak of Data & AI 2025Developing Schemas with FME and Excel - Peak of Data & AI 2025
Developing Schemas with FME and Excel - Peak of Data & AI 2025
Safe Software
 
End-to-end Assurance for SD-WAN & SASE with ThousandEyes
End-to-end Assurance for SD-WAN & SASE with ThousandEyesEnd-to-end Assurance for SD-WAN & SASE with ThousandEyes
End-to-end Assurance for SD-WAN & SASE with ThousandEyes
ThousandEyes
 
DevOps in the Modern Era - Thoughtfully Critical Podcast
DevOps in the Modern Era - Thoughtfully Critical PodcastDevOps in the Modern Era - Thoughtfully Critical Podcast
DevOps in the Modern Era - Thoughtfully Critical Podcast
Chris Wahl
 
ISOIEC 42005 Revolutionalises AI Impact Assessment.pptx
ISOIEC 42005 Revolutionalises AI Impact Assessment.pptxISOIEC 42005 Revolutionalises AI Impact Assessment.pptx
ISOIEC 42005 Revolutionalises AI Impact Assessment.pptx
AyilurRamnath1
 
LSNIF: Locally-Subdivided Neural Intersection Function
LSNIF: Locally-Subdivided Neural Intersection FunctionLSNIF: Locally-Subdivided Neural Intersection Function
LSNIF: Locally-Subdivided Neural Intersection Function
Takahiro Harada
 
Murdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementaryMurdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementary
JorgeSemperteguiMont
 
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdfHow Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
Rejig Digital
 
“How Qualcomm Is Powering AI-driven Multimedia at the Edge,” a Presentation f...
“How Qualcomm Is Powering AI-driven Multimedia at the Edge,” a Presentation f...“How Qualcomm Is Powering AI-driven Multimedia at the Edge,” a Presentation f...
“How Qualcomm Is Powering AI-driven Multimedia at the Edge,” a Presentation f...
Edge AI and Vision Alliance
 
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
angelo60207
 
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdfBoosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Alkin Tezuysal
 
How to Detect Outliers in IBM SPSS Statistics.pptx
How to Detect Outliers in IBM SPSS Statistics.pptxHow to Detect Outliers in IBM SPSS Statistics.pptx
How to Detect Outliers in IBM SPSS Statistics.pptx
Version 1 Analytics
 
If You Use Databricks, You Definitely Need FME
If You Use Databricks, You Definitely Need FMEIf You Use Databricks, You Definitely Need FME
If You Use Databricks, You Definitely Need FME
Safe Software
 
FCF- Getting Started in Cybersecurity 3.0
FCF- Getting Started in Cybersecurity 3.0FCF- Getting Started in Cybersecurity 3.0
FCF- Getting Started in Cybersecurity 3.0
RodrigoMori7
 
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdfcnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
AmirStern2
 
TimeSeries Machine Learning - PyData London 2025
TimeSeries Machine Learning - PyData London 2025TimeSeries Machine Learning - PyData London 2025
TimeSeries Machine Learning - PyData London 2025
Suyash Joshi
 
6th Power Grid Model Meetup - 21 May 2025
6th Power Grid Model Meetup - 21 May 20256th Power Grid Model Meetup - 21 May 2025
6th Power Grid Model Meetup - 21 May 2025
DanBrown980551
 
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc Webinar - 2025 Global Privacy SurveyTrustArc Webinar - 2025 Global Privacy Survey
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc
 
Oracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI FoundationsOracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI Foundations
VICTOR MAESTRE RAMIREZ
 
Soulmaite review - Find Real AI soulmate review
Soulmaite review - Find Real AI soulmate reviewSoulmaite review - Find Real AI soulmate review
Soulmaite review - Find Real AI soulmate review
Soulmaite
 
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
“State-space Models vs. Transformers for Ultra-low-power Edge AI,” a Presenta...
Edge AI and Vision Alliance
 
Developing Schemas with FME and Excel - Peak of Data & AI 2025
Developing Schemas with FME and Excel - Peak of Data & AI 2025Developing Schemas with FME and Excel - Peak of Data & AI 2025
Developing Schemas with FME and Excel - Peak of Data & AI 2025
Safe Software
 
End-to-end Assurance for SD-WAN & SASE with ThousandEyes
End-to-end Assurance for SD-WAN & SASE with ThousandEyesEnd-to-end Assurance for SD-WAN & SASE with ThousandEyes
End-to-end Assurance for SD-WAN & SASE with ThousandEyes
ThousandEyes
 
DevOps in the Modern Era - Thoughtfully Critical Podcast
DevOps in the Modern Era - Thoughtfully Critical PodcastDevOps in the Modern Era - Thoughtfully Critical Podcast
DevOps in the Modern Era - Thoughtfully Critical Podcast
Chris Wahl
 
ISOIEC 42005 Revolutionalises AI Impact Assessment.pptx
ISOIEC 42005 Revolutionalises AI Impact Assessment.pptxISOIEC 42005 Revolutionalises AI Impact Assessment.pptx
ISOIEC 42005 Revolutionalises AI Impact Assessment.pptx
AyilurRamnath1
 
LSNIF: Locally-Subdivided Neural Intersection Function
LSNIF: Locally-Subdivided Neural Intersection FunctionLSNIF: Locally-Subdivided Neural Intersection Function
LSNIF: Locally-Subdivided Neural Intersection Function
Takahiro Harada
 
Murdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementaryMurdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementary
JorgeSemperteguiMont
 
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdfHow Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
How Advanced Environmental Detection Is Revolutionizing Oil & Gas Safety.pdf
Rejig Digital
 

Python programming : List and tuples

  • 3. List Introduction  Used for storing different types of data unlike arrays Example-1 student = [10, "Amar", 'M', 50, 55, 57, 67, 47] Example-2 e_list = [] #Empty List  Indexing + Slicing can be applied on list Example-1 print(student[1]) Gives "Amar" Example-2 print(student[0: 3: 1]) Prints [10, "Amar", 'M'] Example-3 student[::] Print all elements
  • 4. List Examples Example-1 #Create list with integer numbers num = [10, 20, 30, 40, 50] print(num) print("num[0]: %dtnum[2]: %dn" % (num[0], num[2])) Example-2 #Create list with strings names = ["Ram", "Amar", "Thomas"] print(names) print("names[0]: %stnames[2]: %sn" % (names[0], names[2])) Example-3 #Create list with different dtypes x = [10, 20, 1.5, 6.7, "Ram", 'M'] print(x) print("x[0]: %dtx[2]: %ftx[4]: %stx[5]: %cn" %(x[0], x[2], x[4], x[5]))
  • 5. List Creating list using range() Example #Create list num = list(range(4, 9, 2)) print(num)
  • 6. List Updating list 1 Creation lst = list(range(1, 5)) print(lst) [1, 2, 3, 4] 2 append lst.append(9) print(lst) [1, 2, 3, 4, 9] 3 Update-1 lst[1] = 8 print(lst) [1, 8, 3, 4, 9] 4 Update-2 lst[1: 3] = 10, 11 print(lst) [1, 10, 11, 4, 9] 5 delete del lst[1] print(lst) [1, 11, 4, 9] 6 remove lst.remove(11) print(lst) [1, 4, 9] 7 reverse lst.reverse() print(lst) [9, 4, 1]
  • 7. List Concatenation of Two List '+' operator is used to join two list Example x = [10, 20, 30] y = [5, 6, 7] print(x + y)
  • 8. List Repetition of List '*' is used to repeat the list 'n' times Example x = [10, 20, 30] print(x * 2)
  • 9. List Membership of List 'in' and 'not in' operators are used to check, whether an element belongs to the list or not Example x = [1, 2, 3, 4, 5] a = 3 print(a in x) Returns True, if the item is found in the list Example x = [1, 2, 3, 4, 5] a = 7 print(a not in x) Returns True, if the item is not found in the list
  • 10. List Aliasing And Cloning Lists Aliasing: Giving new name for the existing list Example x = [10, 20, 30, 40] y = x Note: No separate memory will be allocated for y Cloning / Copy: Making a copy Example x = [10, 20, 30, 40] y = x[:] <=> y = x.copy() x[1] = 99 print(x) print(y) Note: Changes made in one list will not reflect other
  • 11. List Exercise 1. To find the maximum & minimum item in a list of items 2. Implement Bubble sort 3. To know how many times an element occurred in the list 4. To create employee list and search for the particular employee
  • 12. List To find the common items #To find the common item in two lists l1 = ["Thomas", "Richard", "Purdie", "Chris"] l2 = ["Ram", "Amar", "Anthony", "Richard"] #Covert them into sets s1 = set(l1) s2 = set(l2) #Filter intersection of two sets s3 = s1.intersection(s2) #Convert back into the list common = list(s3) print(common)
  • 13. List Nested List #To create a list with another list as element list = [10, 20, 30, [80, 90]] print(list)
  • 14. List List Comprehensions Example-1: Create a list with squares of integers from 1 to 10 #Version-1 squares = [] for x in range(1, 11): squares.append(x ** 2) print(squares) #Version-2 squares = [] squares = [x ** 2 for x in range(1, 11)] print(squares)  List comprehensions represent creation of new lists from an iterable object(list, set,  tuple, dictionary or range) that satisfies a given condition
  • 15. List List Comprehensions Example-2: Get squares of integers from 1 to 10 and take only the even numbers from the result even_squares = [x ** 2 for x in range(1, 11) if x % 2 == 0] print(even_squares)  List comprehensions represent creation of new lists from an iterable object(list, set,  tuple, dictionary or range) that satisfies a given condition
  • 16. List List Comprehensions Example-3: #Adding the elements of two list one by one #Example-1 x = [10, 20, 30] y = [1, 2, 3, 4] lst = [] #Version-1 for i in x: for j in y: lst.append(i + j) #Version-2 lst = [i + j for i in x for j in y] #Example-2 lst = [i + j for i in "ABC" for j in "DE"] print(lst)  List comprehensions represent creation of new lists from an iterable object(list, set,  tuple, dictionary or range) that satisfies a given condition
  • 17. Tuple
  • 18. Tuple Introduction  A tuple is similar to list but it is immutable
  • 19. Tuple Creating Tuples To create empty tuple tup1 = () Tuple with one item tup1 = (10, ) Tuple with different dtypes tup3 = (10, 20, 1.1, 2.3, "Ram", 'M') Tuple with no braces t4 = 10, 20, 30, 40 Create tuple from the list list = [10, 1.2, "Ram", 'M'] t5 = tuple(list) Create tuple from range t6 = tuple(range(4, 10, 2))
  • 20. Tuple Accessing Tuples  Accessing items in the tuple can be done by indexing or slicing method, similar to that of list
  • 21. Tuple Basic Operations On Tuples s = (10, "Ram", 10, 20, 30, 40, 50) To find the length of the tuple print(len(s)) Repetition operator fee = (25.000, ) * 4 print(fee) Concatenate the tuples using * ns = s + fee print(ns) Membership name = "Ram" print(name in s) Repetition t1 = (1, 2, 3) t2 = t1 * 3 print(t2)
  • 22. Tuple Functions To Process Tuples len() len(tpl) Returns the number of elements in the tuple min() min(tpl) Returns the smallest element in the tuple max() max() Returns the biggest element in the tuple count() tpl.count(x) Returns how many times the element ‘x’ is found in the tuple index() tpl.index(x) Returns the first occurrence of the element ‘x’ in tpl. Raises ValueError if ‘x’ is not found in the tuple sorted() sorted(tpl) Sorts the elements of the tuple into ascending order. sorted(tpl, reverse=True) will sort in reverse order
  • 23. Tuple Exercise 1. To accept elements in the form of a a tuple and display thier sum and average 2. To find the first occurrence of an element in a tuple 3. To sort a tuple with nested tuples 4. To insert a new item into a tuple at a specified location 5. To modify or replace an existing item of a tuple with new item 6. To delete an element from a particular position in the tuple