The document discusses lists in Python. It defines lists as collections of values separated by commas and enclosed in square brackets. It provides examples of creating lists and performing common operations like concatenation, repetition, slicing, membership testing, indexing, updating/changing elements, and built-in functions/methods like len(), min(), max(), sort(), and reverse(). The document also covers iterating through lists using for loops and deleting elements using the del statement.
• List is a collection, which is ordered and changeable. Allows duplicate members.
• Tuple is a collection, which is ordered and unchangeable. Allows duplicate members.
• Set is a collection, which is unordered and unindexed. No duplicate members.
• Dictionary is a collection, which is unordered, changeable and indexed. No duplicate members.
This presentation about Python Interview Questions will help you crack your next Python interview with ease. The video includes interview questions on Numbers, lists, tuples, arrays, functions, regular expressions, strings, and files. We also look into concepts such as multithreading, deep copy, and shallow copy, pickling and unpickling. This video also covers Python libraries such as matplotlib, pandas, numpy,scikit and the programming paradigms followed by Python. It also covers Python library interview questions, libraries such as matplotlib, pandas, numpy and scikit. This video is ideal for both beginners as well as experienced professionals who are appearing for Python programming job interviews. Learn what are the most important Python interview questions and answers and know what will set you apart in the interview process.
Simplilearn’s Python Training Course is an all-inclusive program that will introduce you to the Python development language and expose you to the essentials of object-oriented programming, web development with Django and game development. Python has surpassed Java as the top language used to introduce U.S. students to programming and computer science. This course will give you hands-on development experience and prepare you for a career as a professional Python programmer.
What is this course about?
The All-in-One Python course enables you to become a professional Python programmer. Any aspiring programmer can learn Python from the basics and go on to master web development & game development in Python. Gain hands on experience creating a flappy bird game clone & website functionalities in Python.
What are the course objectives?
By the end of this online Python training course, you will be able to:
1. Internalize the concepts & constructs of Python
2. Learn to create your own Python programs
3. Master Python Django & advanced web development in Python
4. Master PyGame & game development in Python
5. Create a flappy bird game clone
The Python training course is recommended for:
1. Any aspiring programmer can take up this bundle to master Python
2. Any aspiring web developer or game developer can take up this bundle to meet their training needs
Learn more at https://www.simplilearn.com/mobile-and-software-development/python-development-training
Python is a widely used high-level programming language for general-purpose programming. Python is a simple, powerful and easy to learn the programming language. It is commonly used for Web and Internet development, Scientific and Numeric computing, Business application and Desktop GUI development etc. The basic data structures in python are lists, dictionaries, tuples, strings and sets
• List is a collection, which is ordered and changeable. Allows duplicate members.
• Tuple is a collection, which is ordered and unchangeable. Allows duplicate members.
• Set is a collection, which is unordered and unindexed. No duplicate members.
• Dictionary is a collection, which is unordered, changeable and indexed. No duplicate members.
This presentation about Python Interview Questions will help you crack your next Python interview with ease. The video includes interview questions on Numbers, lists, tuples, arrays, functions, regular expressions, strings, and files. We also look into concepts such as multithreading, deep copy, and shallow copy, pickling and unpickling. This video also covers Python libraries such as matplotlib, pandas, numpy,scikit and the programming paradigms followed by Python. It also covers Python library interview questions, libraries such as matplotlib, pandas, numpy and scikit. This video is ideal for both beginners as well as experienced professionals who are appearing for Python programming job interviews. Learn what are the most important Python interview questions and answers and know what will set you apart in the interview process.
Simplilearn’s Python Training Course is an all-inclusive program that will introduce you to the Python development language and expose you to the essentials of object-oriented programming, web development with Django and game development. Python has surpassed Java as the top language used to introduce U.S. students to programming and computer science. This course will give you hands-on development experience and prepare you for a career as a professional Python programmer.
What is this course about?
The All-in-One Python course enables you to become a professional Python programmer. Any aspiring programmer can learn Python from the basics and go on to master web development & game development in Python. Gain hands on experience creating a flappy bird game clone & website functionalities in Python.
What are the course objectives?
By the end of this online Python training course, you will be able to:
1. Internalize the concepts & constructs of Python
2. Learn to create your own Python programs
3. Master Python Django & advanced web development in Python
4. Master PyGame & game development in Python
5. Create a flappy bird game clone
The Python training course is recommended for:
1. Any aspiring programmer can take up this bundle to master Python
2. Any aspiring web developer or game developer can take up this bundle to meet their training needs
Learn more at https://www.simplilearn.com/mobile-and-software-development/python-development-training
Python is a widely used high-level programming language for general-purpose programming. Python is a simple, powerful and easy to learn the programming language. It is commonly used for Web and Internet development, Scientific and Numeric computing, Business application and Desktop GUI development etc. The basic data structures in python are lists, dictionaries, tuples, strings and sets
Palestine last event orientationfvgnh .pptxRaedMohamed3
An EFL lesson about the current events in Palestine. It is intended to be for intermediate students who wish to increase their listening skills through a short lesson in power point.
Instructions for Submissions thorugh G- Classroom.pptxJheel Barad
This presentation provides a briefing on how to upload submissions and documents in Google Classroom. It was prepared as part of an orientation for new Sainik School in-service teacher trainees. As a training officer, my goal is to ensure that you are comfortable and proficient with this essential tool for managing assignments and fostering student engagement.
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxEduSkills OECD
Andreas Schleicher presents at the OECD webinar ‘Digital devices in schools: detrimental distraction or secret to success?’ on 27 May 2024. The presentation was based on findings from PISA 2022 results and the webinar helped launch the PISA in Focus ‘Managing screen time: How to protect and equip students against distraction’ https://www.oecd-ilibrary.org/education/managing-screen-time_7c225af4-en and the OECD Education Policy Perspective ‘Students, digital devices and success’ can be found here - https://oe.cd/il/5yV
How to Split Bills in the Odoo 17 POS ModuleCeline George
Bills have a main role in point of sale procedure. It will help to track sales, handling payments and giving receipts to customers. Bill splitting also has an important role in POS. For example, If some friends come together for dinner and if they want to divide the bill then it is possible by POS bill splitting. This slide will show how to split bills in odoo 17 POS.
Unit 8 - Information and Communication Technology (Paper I).pdfThiyagu K
This slides describes the basic concepts of ICT, basics of Email, Emerging Technology and Digital Initiatives in Education. This presentations aligns with the UGC Paper I syllabus.
The French Revolution, which began in 1789, was a period of radical social and political upheaval in France. It marked the decline of absolute monarchies, the rise of secular and democratic republics, and the eventual rise of Napoleon Bonaparte. This revolutionary period is crucial in understanding the transition from feudalism to modernity in Europe.
For more information, visit-www.vavaclasses.com
The Roman Empire A Historical Colossus.pdfkaushalkr1407
The Roman Empire, a vast and enduring power, stands as one of history's most remarkable civilizations, leaving an indelible imprint on the world. It emerged from the Roman Republic, transitioning into an imperial powerhouse under the leadership of Augustus Caesar in 27 BCE. This transformation marked the beginning of an era defined by unprecedented territorial expansion, architectural marvels, and profound cultural influence.
The empire's roots lie in the city of Rome, founded, according to legend, by Romulus in 753 BCE. Over centuries, Rome evolved from a small settlement to a formidable republic, characterized by a complex political system with elected officials and checks on power. However, internal strife, class conflicts, and military ambitions paved the way for the end of the Republic. Julius Caesar’s dictatorship and subsequent assassination in 44 BCE created a power vacuum, leading to a civil war. Octavian, later Augustus, emerged victorious, heralding the Roman Empire’s birth.
Under Augustus, the empire experienced the Pax Romana, a 200-year period of relative peace and stability. Augustus reformed the military, established efficient administrative systems, and initiated grand construction projects. The empire's borders expanded, encompassing territories from Britain to Egypt and from Spain to the Euphrates. Roman legions, renowned for their discipline and engineering prowess, secured and maintained these vast territories, building roads, fortifications, and cities that facilitated control and integration.
The Roman Empire’s society was hierarchical, with a rigid class system. At the top were the patricians, wealthy elites who held significant political power. Below them were the plebeians, free citizens with limited political influence, and the vast numbers of slaves who formed the backbone of the economy. The family unit was central, governed by the paterfamilias, the male head who held absolute authority.
Culturally, the Romans were eclectic, absorbing and adapting elements from the civilizations they encountered, particularly the Greeks. Roman art, literature, and philosophy reflected this synthesis, creating a rich cultural tapestry. Latin, the Roman language, became the lingua franca of the Western world, influencing numerous modern languages.
Roman architecture and engineering achievements were monumental. They perfected the arch, vault, and dome, constructing enduring structures like the Colosseum, Pantheon, and aqueducts. These engineering marvels not only showcased Roman ingenuity but also served practical purposes, from public entertainment to water supply.
The Indian economy is classified into different sectors to simplify the analysis and understanding of economic activities. For Class 10, it's essential to grasp the sectors of the Indian economy, understand their characteristics, and recognize their importance. This guide will provide detailed notes on the Sectors of the Indian Economy Class 10, using specific long-tail keywords to enhance comprehension.
For more information, visit-www.vavaclasses.com
Model Attribute Check Company Auto PropertyCeline George
In Odoo, the multi-company feature allows you to manage multiple companies within a single Odoo database instance. Each company can have its own configurations while still sharing common resources such as products, customers, and suppliers.
2. List in Python
• In python, a list can be defined as a collection of values or
items.
• The items in the list are separated with the comma (,) and
enclosed with the square brackets [ ].
Syntax:
list_name= [ item1, item2,item3…. ]
Example: “listdemo.py”
L1 = []
L2 = [123,"python", 3.7]
L3 = [1, 2, 3, 4, 5, 6]
L4 = ["C","Java","Python"]
print(L1)
print(L2)
print(L3)
print(L4)
Output:
python listdemo.py
[]
[123, 'python', 3.7]
[1, 2, 3, 4, 5, 6]
['C','Java','Python']
4. List Operators in Python
+
It is known as concatenation operator used to concatenate two
lists.
*
It is known as repetition operator. It concatenates the multiple
copies of the same list.
[]
It is known as slice operator. It is used to access the list item
from list.
[:]
It is known as range slice operator. It is used to access the range
of list items from list.
in
It is known as membership operator. It returns if a particular
item is present in the specified list.
not in
It is also a membership operator and It returns true if a
particular list item is not present in the list.
5. List Operators in Python cont…
Example: “listopdemo.py”
num=[1,2,3,4,5]
lang=['python','c','java','php']
print(num + lang) #concatenates two lists
print(num * 2) #concatenates same list 2 times
print(lang[2]) # prints 2nd index value
print(lang[1:4]) #prints values from 1st to 3rd index.
print('cpp' in lang) # prints False
print(6 not in num) # prints True
Output: python listopdemo.py
[1, 2, 3, 4, 5, 'python', 'c', 'java', 'php']
[1, 2, 3, 4, 5, 1, 2, 3, 4, 5]
java
['c', 'java', 'php']
False
True
7. List Indexing in Python
• Like string sequence, the indexing of the python lists starts from 0,
i.e. the first element of the list is stored at the 0th index, the second
element of the list is stored at the 1st index, and so on.
• The elements of the list can be accessed by using the slice operator
[].
• The syntax for accessing an item in a list is,
• list_name[index]
Example:
mylist=[‘banana’,’apple’,’mango’,’tomato’,’berry’]
• mylist[0]=”banana” mylist[1:3]=[”apple”,”mango”]
• mylist[2]=”mango”
8. List Indexing in Python cont…
• Unlike other languages, python provides us the flexibility to use
the negative indexing also. The negative indices are counted
from the right.
• The last element (right most) of the list has the index -1, its
adjacent left element is present at the index -2 and so on until
the left most element is encountered.
Example: mylist=[‘banana’,’apple’,’mango’,’tomato’,’berry’]
• mylist[-1]=”berry” mylist[-4:-2]=[“apple”,mango”]
• mylist[-3]=”mango” mvlist[ -3 : ]=[“mango”,”tomato”,’berry’]
9. Slicing in list
• Slicing of lists is allowed in Python wherein a part of the list
can be extracted by
• specifying index range along with the colon (:) operator which
itself is a list.
• The syntax for list slicing is,
•
• List slicing returns a part of the list from the start index value
to stop index value which includes the start index value but
excludes the stop index value. Step specifies the increment
value to slice by and it is optional.
11. How to update or change elements to a list?
• Python allows us to modify the list items by using the slice and
assignment operator.
• We can use assignment operator ( = ) to change an item or a
range of items.
Example: “listopdemo1.py”
num=[1,2,3,4,5]
print(num)
num[2]=30
print(num)
num[1:3]=[25,36]
print(num)
num[4]="Python"
print(num)
List1=num1
Print(list1)
Output:
python listopdemo1.py
[1, 2, 3, 4, 5]
[1, 2, 30, 4, 5]
[1, 25, 36, 4, 5]
[1, 25, 36, 4, 'Python']
[1, 25, 36, 4, ‘python’]
13. List Functions & Methods in Python
• Python provides various in-built functions .Those are
☞ len():
• In Python, len() function is used to find the length of list,i.e it
returns the number of items in the list..
Syntax: len(list)
• len()
• any()
• all()
• sum()
• sorted()
Example: listlendemo.py
num=[1,2,3,4,5,6]
print("length of list :",len(num))
Output:
python listlendemo.py
length of list : 6
14. • ☞ any():
• The any() function returns True if any of the Boolean
values in the list is True.
• Syntax: any(iterable)
• Iterable: It is an iterable object such as a dictionary,
tuple, list, set, etc.
• Ex:
• any([1, 1, 0, 0, 1, 0])
• True
• any(0,0,0,0)
• False
• list2=[1,0,2]
• any(list2)
• True
15. • ☞ all():
• The all() function returns True if all the Boolean values in the
list are True, else returns False.
• Syntax: any(iterable)
• Iterable: It is an iterable object such as a dictionary, tuple, list,
set, etc.
• Ex:
• >>> all([1, 1, 1, 1])
• True
• >>> all([1,0,2])
• False
• >>> all([1,2,3,4,5,])
• True
16. List Functions in Python Cont..
☞ sum ():
• In python, sum() function returns sum of all values in the list. List
values must in number type.
Syntax: sum(list)
Example: listsumdemo.py
list1=[1,2,3,4,5,6]
print("Sum of list items :",sum(list1))
Output:
python listsumdemo.py
Sum of list items : 21
17. List Functions in Python Cont..
☞ sorted ():
• The sorted() function returns a modified copy of the list while
leaving the original list untouched.
Syntax: sorted(list)
Example: sorteddemo.py
num=[23,5,78,9]
print(sorted(num))
[5, 9, 23, 78]
print(num)
[23, 5, 78, 9]
19. List Functions & Methods in Python
• Python provides various methods which can be used with list.
• Those are
• extend
• max()
• min()
• list()
•append()
• remove()
• sort()
• reverse()
• count()
• index()
• insert()
• pop()
• clear()
20. List Methods in Python Cont..
☞ max ():
• In Python, max() function is used to find maximum value in the list.
Syntax: max(list)
Example: listmaxdemo.py
list1=[1,2,3,4,5,6]
list2=['java','c','python','cpp']
print("Max of list1 :",max(list1))
print("Max of list2 :",max(list2))
Output:
python listmaxdemo.py
Max of list1 : 6
Max of list2 : python
21. List Methods in Python Cont..
☞ min ():
• In Python, min() function is used to find minimum value in the list.
Syntax: min(list)
Example: listmindemo.py
list1=[1,2,3,4,5,6]
list2=['java','c','python','cpp']
print("Min of list1 :",min(list1))
print("Min of list2 :",min(list2))
Output:
python listmindemo.py
Min of list1 : 1
Min of list2 : c
22. List Methods in Python Cont..
☞ list ():
• In python, list() is used to convert given sequence (string or tuple)
into list.
Syntax: list(sequence)
Example: listdemo.py
str="python"
list1=list(str)
print(list1)
Output:
python listdemo.py
['p', 'y', 't', 'h', 'o', 'n']
23. List Methods in Python Cont..
☞ append ():
The append() method adds a single item to the end of the list. This
method does not return new list and it just modifies the original.
Syntax: list.append(item)
where item may be number, string, list and etc.
Example: num=[1,2,3,4,5]
lang=['python','java']
num.append(6)
print(num)
lang.append("cpp")
print(lang)
list=[1,2,3,4]
list.append([6,7])
print(list)
Output:
python appenddemo.py
[1, 2, 3, 4, 5, 6]
['python', 'java', 'cpp']
[1, 2, 3, 4, [6, 7]]
24. List Methods in Python Cont..
☞ remove ():
• In python, remove() method removes item from the list. It removes
first occurrence of item if list contains duplicate items. It throws an
“value error” if the item is not present in the list.
Syntax: list.remove(item)
Example: removedemo.py
list1=[1,2,3,4,5]
list2=['A','B','C','B','D']
list1.remove(2)
print(list1)
list2.remove("B")
print(list2)
list2.remove("E")
print(list2)
Output:
python removedemo.py
[1, 3, 4, 5]
['A', 'C', 'B', 'D']
ValueError: x not in list
25. List Methods in Python Cont..
☞ sort ():
• In python, sort() method sorts the list elements into descending or
ascending order. By default, list sorts the elements into ascending
order. It takes an optional parameter 'reverse' which sorts the list
into descending order. This method modifies the original list.
Syntax: list.sort()
Example: sortdemo.py
list1=[6,8,2,4,10]
list1.sort()
print("n After Sorting:n")
print(list1)
print("Descending Order:n")
list1.sort(reverse=True)
print(list1)
Output:
python sortdemo.py
After Sorting:
[2, 4, 6, 8 , 10]
Descending Order:
[10, 8, 6, 4 , 2]
26. List Methods in Python Cont..
☞ reverse ():
• In python, reverse() method reverses elements of the list. i.e. the
last index value of the list will be present at 0th index. This method
modifies the original list and it does not return a new list.
Syntax: list.reverse()
Example: reversedemo.py
list1=[6,8,2,4,10]
list1.reverse()
print("n After reverse:n")
print(list1)
Output:
python reversedemo.py
After reverse:
[10, 4, 2, 8 , 6]
27. List Methods in Python Cont..
☞ count():
• In python, count() method returns the number of times an element
appears in the list. If the element is not present in the list, it
returns 0.
Syntax: list.count(item)
Example: countdemo.py
num=[1,2,3,4,3,2,2,1,4,5,8]
cnt=num.count(2)
print("Count of 2 is:",cnt)
cnt=num.count(10)
print("Count of 10 is:",cnt) Output:
python countdemo.py
Count of 2 is: 3
Count of 10 is: 0
28. List Methods in Python Cont..
☞ index():
• In python, index () method returns index of the passed element. If
the element is not present, it raises a ValueError.
• If list contains duplicate elements, it returns index of first
occurred element.
• This method takes two more optional parameters start and end
which are used to search index within a limit.
Syntax: list. index(item [, start[, end]])
Example: indexdemo.py
list1=['p','y','t','o','n','p']
print(list1.index('t'))
Print(list1.index('p'))
Print(list1.index('p',3,10))
Print(list1.index('z')) )
Output:
python indexdemo.py
2
0
5
Value Error
29. List Methods in Python Cont..
☞ insert():
• In python, the insert() method inserts the item at the given index,
shifting items to the right.
Syntax: list.insert(index,item)
Example: insertdemo.py
num=[10,20,30,40,50]
num.insert(4,60)
print(num)
num.insert(7,70)
print(num)
Output:
python insertdemo.py
[10, 20, 30, 40, 60, 50]
[10, 20, 30, 40, 60, 50, 70]
30. List Methods in Python Cont..
☞ pop():
• In python, pop() element removes an element present at specified
index from the list.
Syntax: list.pop(index)
Example: popdemo.py
num=[10,20,30,40,50]
num.pop()
print(num)
num.pop(2)
print(num)
num.pop(7)
print(num)
Output:
python popdemo.py
[10, 20, 30, 40]
[10, 20, 40]
IndexError: Out of range
31. List Methods in Python Cont..
☞ clear():
• In python, clear() method removes all the elements from the list.
It clears the list completely and returns nothing.
Syntax: list.clear()
Example: cleardemo.py
num=[10,20,30,40,50]
num.clear()
print(num)
Output:
python cleardemo.py
[ ]
32. List Methods in Python Cont..
☞ Extend():
The extend() method adds the items in list2 to the end of the list.
Syntax: list.extend(list2)
Example: cleardemo.py
list=[1,3,2]
list1=[0,5,6]
list.extend(list1)
print(list) Output:
[1, 3, 2, 0, 5, 6]
33. Iterating a List
• A list can be iterated by using a for - in loop. A simple list
containing four strings can be iterated as follows..
Example: “listopdemo3.py”
lang=['python','c','java','php‘]
print("The list items are n")
for i in lang:
print(i)
Output:
python listopdemo3.py
The list items are
python
c
java
php
34. How to delete or remove elements from a list?
• Python allows us to delete one or more items in a list by using
the del keyword.
• .The difference between del statement and pop() function is
that the del statement does not return any value while the
pop() function returns a value.
• The del statement can also be used to remove slices from a list
or clear the entire list.
35. How to delete or remove elements from a list?
Example:
“listopdemo2.py”
num = [1,2,3,4,5]
print(num)
del num[1]
print(num)
del num[1:3]
print(num)
del num[:]
Output:
python listopdemo2.py
[1, 2, 3, 4, 5]
[1, 3, 4, 5]
[1, 5]
[]
36. Nested list
• A list inside another list is called a nested list and you can get
the behavior of nested lists in Python by storing lists within the
elements of another list.
• You can traverse through the items of nested lists using the for
loop.
• The syntax for nested lists is
Ex: nested_list=[[item1,item2,item3],
[item4,item5,item6],
[item7,item8,item9]]
nested_list[0]= [item1,item2,item3]
nested_list[1]= [item4,item5,item6]
nested_list[2]= [item7,item8,item9]
nested_list[0][1]=[item2]