Python Lecture 3
Python Lecture 3
Python
Lets learn something New
1
Click to edit
Lecture 3 Master title style
LIST
TUPLE
2 2
Click to edit Master title style
List in Python
A built-in data type that stores set of values
It can store elements of different types (integer, float, string, etc.)
List is mutable…..
4 4
Click to edit Master title style
List Methods
list = [2, 1, 3]
6 6
Click to edit Master title style
Tuple Methods
tup = (2, 1, 3, 1)
7 7
Click to edit Master title style
Lets practice
1. ask the user to enter names of their 3 favorite movies & store them
in a list..
ans: m1=input(m1),m2=input(m2),m3=input(m3)
MOVIES=[]
MOVIES.APPEND()
2. check if a list contains a palindrome of elements. (Hint: use copy( )
method)
[1,2,3,2,1] OR [1,’ABC’,’ABC’,1]
8 8
Click to edit Master title style
Lets practice
1. count the number of students with the “A” grade in the following
tuple.
(”C”, “D”, “A”, “A”, “B”, “B”, “A”)
2. Store the above values in a list & sort them from “A” to “D”.
9 9