You are on page 1of 1

Expert

Q1 Write a Python program to create a list by concatenating a given list which range goes
from 1 to n.

my_list = ['p', 'q']

Output: ['p1', 'q1', 'p2', 'q2', 'p3', 'q3', 'p4', 'q4']

Q2. Write a Python program to get the difference between the two lists.

list1 = [1, 3, 5, 7, 9]

list2=[1, 2, 4, 6, 7, 8]

Output:

[9, 3, 5, 8, 2, 4, 6]

Q3. Take a list of 10 elements. Split it into middle and store the elements in two dfferent lists.
list : 58 24 13 15 63 9 8 81 1 78

Output=
List1=[58,24,13,15]
List2=[63,9,8,81,1,78]

Q4. Create one list with names of your five friends. Return the position of your best friend in
the list.

1. Add one name Alex to above list. ( append())


2. Add name ‘Ronn’ to 2nd position ( insert()).
3. Create two list and then merger 2nd list with first list and display the output ( extend()
)
4. Create a copy of your friends list
5. Remove one element from the list ( specify the name )
6. Remove the 2nd element from the list and display the removed element ( use pop() )

You might also like