1. Write the output of the following code.
A = [2, 4, 6, 8,10]
L = len (A)
S = 0
for I in range (1, L, 2):
S += A[I]
print("Sum=", S)
2. Write a program in Python to do linear search of an element in a list of
integers.
3. Write a program in Python to input a list and count the frequency of an element
in that list.
4. Given a list L= [10, 20, 30, 40, 50, 60, 70], what would L[2:-2] return?
5. Start with the list [8, 9, 10]. Do the following using list functions:
1. Set the second entry (index 1) to 17
2. Add 4, 5 and 6 to the end of the list
3. Remove the first entry from the list
4. Sort the list
5. Double the list
6. Insert 25 at index 3
6. What is the difference between these two statements?
t= 6,7,8
t=(6,7,8)
7. Write the output of the following code.
t = (14,34,54,74,94)
ft = (14,34,54,74,94)
for i in range(len(t)):
if i%2==0:
print(i-3,"#",end="")
print()
print(t[-1]+t[-2]+t[-3])
print(ft[4]-t[2]-t[0])
8. How you can join multiple tuples? Explain with example.
9. How you can check the availability of a value in a tuple? Explain all the ways
to check it.
10. What is the significance of this statement with respect to a tuple in python?
1. t=(“T”)
2. t=(“T”,)
3. t=(‘T’,)
11. Consider the following dictionary :
stateCapital = {"AndhraPradesh":"Hyderabad","Bihar":"Patna","Maharashtra":"Mumbai",
"Rajasthan":"Jaipur"}
Find the output of the following statements:
1. print(stateCapital.get("Bihar"))
2. print(stateCapital.keys())
3. print(stateCapital.values())
4. print(stateCapital.items())
5. print(len(stateCapital))
12. Condider a dictionary D with 4 key-value pairs. How D.clear() is different from
del D?
13. Write a program to enter roll number and names of five students and store the
data
in dictionary.