CBSE Today

Python List Assignment -1

Python List is one of the most used data types in python so we need a lot of questions to practice our List skills in python. This Question set aka Assignment on Python will help you to sharpen your knowledge and programming skills.

Python List Assignment

1. What do you mean by List in Python?
2. The elements in the list can be of ______ type (any/fixed)
3. Elements in the list are enclosed in _____ brackets
4. Values in the list are called _______.
5. Lists are ________ in nature (heterogeneous/homogeneous)
6. List is a _________ data type. (Linear/non-linear)
7. Elements in the list are separated by ______.
8. Write the code to create an empty list named ‘L’.
9. Write a code to create list of any three colors named ‘color’.
10. What do you mean by nested list
11. Write the code to create the list of::
a. Five vegetables
b. Vowels
c. First 10 natural numbers
d. Square of first 5 natural numbers.
e. Any five names of your friends
f. All the alphabets of word “Taj Mahal”
g. First five multiples of 6.
12. Write a code to convert the string “Practice” into list.
13. Write the output of the following:
>>> d = “a*hj?”
>>> list(d)
14. Write the output of the following:
>>>a = “String”
>>>list (a)
15. Write the output of the following:
>>> a = list ()
>>> a
16. What is list() function?
17. Write the output of the following:
>>> a = ‘string’
>>> a= input(‘ Enter any string ‘)
>>> a = list(a)

1. Write the output of the following statements
>>>a = [1,2,3,4,5,6]
>>>print(a[0])
>>>print(a[1])
>>>print(a[3])
>>>print(a[-1])
>>> print a[-2])
2. Fill the index value in place of ?. When the output is as follows
A = ‘rakesh kumar’
B = list(A)
Output is
a
k
s
u
m
>>>print(B[?])
>>>print(B[?])
>>>print(B[?])
>>>print(B[-?])
>>>print(B[-?])
3. Write the output of the following code
a)
a = ‘Python is fun’
for x in a:
print(x)
b)
a = ‘Python is fun’
for x in a:
print(x, end =” “)
c)
a = ‘Python is fun’
for x in a:
print(x, end =” ? “)
4. What do you mean by traversing a list?
5. Write a program to print all the elements of given list using for loop.
A = [‘a’,’b’,’c’’,’d’,’e’,’f’ ]
6. List in python are mutable.(T/F)
7. Write the output of the following:
A = [1,2,3,4,5]
B = A
print(A)
print(B)
A[0]=’a’
print(A)
print(B)

8. What do you mean by concatenation in list? Explain with some suitable example
9. Which mathematical operator is used to concatenate list in python
10. Can we multiply two lists?
11. Write the output of the following python commands
>>> a = “python is fun”
>>> b = list(a)
>>> b*2
>>>b+b
>>>a+a
12. Find out the output of the following code segment
S.NO Code Output
1 [1,2,3,4] ==[4,3,2,1]
2 [1,2,3,4] > [4]
3 [1,2,3,4] != [ 1,2,3,4]
4 [1,2,3,4] != [1,2,[3,4]]
5 >>>a = [1,2,3,4]
>>> b = [5,6,7,8]
>>>a+b
6 [1,2,3]==[1.0,2.0,3.0]
7 >>>a = [1,2,3,4,5]
>>>b = [5,6,7,8,9]
>>>a+b
8 >>>a = [1,2,3,4,5]
>>>b = [5,6,7,8,9]
>>>a,b
9 >>>a = [1,2,3,4,5]
>>>b = [5,6,7,8,9]
>>>a*b
10 >>>a = [1,2,3,4,5]
>>>a+10
11 >>>a = [1,2,3,4,5]
>>>a*2

1. Index value of first element in list is ___
2. Index value of last element in list is ____
3. Write one difference between indexing and slicing
4. The syntax of slicing is
List[start : end :step]
Which argument is optional out of start , end and stop
5. Write the output of the following
b= ‘PythonProgramming’
a = list(a)
>>>print(a)
>>>print(len(b))
>>>print(b[1:4])
>>>print(a[3:])
>>>print(a[4:17])
>>>print(a[-2:-5:-1])
>>>print(a[7:1:-1])
>>>print(a[17:-1])
>>>print(print(a[10::-1])
6. Write code to make copy of the following list using copy() method
A = [1,34,56,76]
7. What is the difference between pop(), remove() ? Explain with some suitable example
8. How append() method is different with Index() ? Explain with some suitable example

1. Write a program to create list of the following (take input from the user)
a) Name of any five students
b) Five integer numbers
c) Five float numbers
d) Five alphabets
e) Name of five colors
2. Write a program in python to read 10 numbers from the keyboard. Add the number in a list if the entered number is ODD
Example:
Input : 1,2,3,4,5,6,7,8,9,10
List1 = [1,3,5,7,9]
3. Write a program in python to find out the largest number from a given list of number without using built in max() function.
4. Write a program in Python to find out the second largest number from a given list of number.
5. Write a program in find out the sum of all the numbers in this list
Example
List1 = [1,2,3,4,’ramji’,67.5,10,’anil’]
Sum = 87.5
6. Write the role of reverse() function in list.
7. reverse() function create new list. (T/F)
8. What type of error return by index() function,if element is not present in list?
9. len() function returns the ______ of the list.
10. By default sort() function arrange the element in ……………………………. Order (increasing/decreasing )
11. What do you mean by nested list. Give one example of nested list.
12. Write code to arrange elements of following list in increasing order.
List1 =[34,3,23,56,6,3,6,89,5,34,78,89]
13. Explain the following functions in reference to list with example
a. Pop()
b. Del
c. Remove()
d. Clear()
e. Count()
14. Name a function/statement which can delete more than one element from the list.
15. Write a program to delete/remove all the odd numbers from the list.
16. Write a program to delete/remove all the negative elements from the list.
17. Write a program to delete/remove all the numbers less than 10 from the list.

1. Write a program to input a number and count the occurrence of that number in the given list.
A = [12,34,5,67,78,787,56,43,34,565]
2. Write a program to separate the character and numeric value from a given list and store them in a separate list.
List1 = [1,4,’a’,6,’b’,1,’c’,’d’,12,’e’]
3. What do you mean by sorting?
4. Name any two sorting techniques.
5. Write a program to create a list of 10 integers and sort the list in increasing order using bubble sort method.
6. Suppose total element in a list are 7, so how many times the outer loop will be executed in bubble sort.
7. A = [23,45,21,78,43]
Write the order of the elements in the above list after first pass of bubble sort (in ascending order).

Exit mobile version