Python List Assignment -1


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

Print Friendly, PDF & Email

Related Posts

If you like CBSEToaday and would like to contribute, you can also write an article using submit article or mail your article to contribute@cbsetoday.com See your article appearing on the cbsetoday.com main page and help other students/teachers.