Computer Science - Informatics Practices Class XI/XII Python List Solved Test Part 4
Q1. What do you mean by traversing a list?
Q2. Write a program to print all the elements of given list using for loop.
A = [‘a’,’b’,’c’,’d’,’e’]
Q3. List in python are mutable.(T/F)
Q4. Write the output of the following:
Q5. Write the output of the following:
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 |
[1,2,3] == [1.0,2.0,3.0] |
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
>>> a >>> len(a) |
|
Q6. What do you mean by concatenation in
list? Explain
with example.
Q7. Which mathematical operator is used
to concatenate
the list?
Q8. Which mathematical operator is used
to replicate
the list?
Q9. Write the output of the following:
>>> a= “python”
>>> b=list(a)
>>> b*2
>>> b+b
>>> a+a
Q10. Can we multiply two list?
Solutions:
Ans 1: Traversing means to access each
element of list
Ans 2.
Ans 3. True
Ans 4.
[1,2,3,4]
[1,2,3,4]
[a,2,3,4]
[a,2,3,4]
Ans 5.
S.No. |
Code |
Output |
1 |
[1,2,3,4] == [4,3,2,1] |
False |
2 |
[1,2,3,4] > [4] |
False |
3 |
[1,2,3,4] != [1,2,3,4] |
False |
4 |
[1,2,3,4] == [1,2,[3,4]] |
False |
5 |
[1,2,3] == [1.0,2.0,3.0] |
True |
6 |
|
[1,2,3,4,5,6,7,8] |
7 |
|
[1,2,3,4] |
8 |
|
[1,2,3,4] |
9 |
|
([1,2,3,4],[5,6,7,8]) |
10 |
|
Error |
11 |
|
[1,2,3,4,5,6,7,8] |
12 |
|
Error |
13 |
|
[1,2,3,4,5] |
14 |
|
[1,2,3,4,1,2,3,4] |
15 |
>>> a >>> len(a) |
[1,2,3,4,1,2,3,4] [1,2,3,4] 4 |
Ans 6. Concatenation of list means
combining the two
list. For example :
>>>a = [1,2,3,4]
>>>b = [5,6,7,8]
>>> a+b
Ans 7. ‘+’ operator
Ans 8. ‘*’ operator
Ans 9. ['p', 'y', 't', 'h', 'o', 'n',
'p', 'y', 't', 'h', 'o', 'n']
['p', 'y', 't', 'h',
'o', 'n', 'p', 'y', 't', 'h', 'o', 'n']
'pythonpython'
Ans 10. NO