You are on page 1of 2

Given a List

List1 = [12, 14, 15, 17, 14, 18, 25, 32]


Answer the following questions
1. Display the First and Last element from the List
2. Display the element at 5th position using negative index.
3. What will be the output of the following commands?
(a) print( List1[-4] )
(b) print( List1[4+2] )
4. List1[2]= 19
print (List1)

5. List2 = [5,6,7]
List3 = [9, 15, 21]
List4= List2 + List 3
print (List4)

6. List5 = [“Hi”]
print ( List5 * 5 ]

7. List7= [ 24,38,47]
print ( 24 not in List7)

8. List1 = [12, 14, 15, 17, 14, 18, 25, 32]

(a) print( List1[0:2])


(b) print( List1[3:1])
(c) print( List1[3:10])
(d) print( List1[-1:-4])
(e) print( List1[ : 3])
(f) print( List1[ 4 : ])
(g) print( List1[ 0 : 6 : 2 ])
(h) print( List1[ : : -1 ])

You might also like