Section A
Section A
result = add(3, 5)
print(result)
a) 8 b) 3 + 5 c) 35 d) None
7. What is the primary purpose of a function in Python?
a) To execute a block of code repeatedly
b) To organize code into manageable units and promote code reuse
c) To perform mathematical operations
d) To define conditional statements
8. Assertion (A): In Python, a key should not be duplicated within the
dictionary.
Reason (R): While creating a dictionary, a key and its value are separated
by a colon (:) and the key: value pairs are separated by commas (.) All the
key: value pairs are enclosed within the curly braces {}.
Section B
Each question 2 marks
9. Define function?
10. List out advantages of function?
11. Differentiate global and local variable?
Section C
Each question 3 marks
12.Predict the output of the following code:
d = {"apple": 15, "banana": 7, "cherry": 9}
str1 = ""
for key in d:
str1 = str1 + str(d[key]) + "@" + “\n”
str2 = str1[:-1]
print(str2)
Section D
Each questions 4 marks
13. Consider the following dictionary Bus
Bus={‘A1 Travels’:[‘Banglore’,’Kottayam’,’Ac’,1650],
’TVK Travels’:[‘Banglore’,’Hydrabad’,’Non AC’,2350],
‘RKR Travels’:[‘Banglore’,’Trivandrum’,’Non AC’,2000],
‘KBS Travels’:[‘Banglore’,’Chennai’,’AC’,1350],
‘Mythri’:[‘Banglore’,’Hydrabad’,’AC’,2750]}
a. Display Bus name all Non AC bus.
b. Display the bus name and price of all the bus which amount is grater than
1800
c. Display the name of bus which contain more than 10 character in its name
14.A dictionary Cinema has the following structure:
{MNO:[MNAME, MTYPE]}
Where MNO – Movie Number ,MNAME – Movie Name, MTYPE is Movie Type
Write a program that accepts mtype as the movie type from user and
displays all the records from the dictionary CINEMA, that have the value of
Movie Type as mtype.
Section E
15.
a. Predict the output of the following code
D={"Saurav":80,"Aditi":89, "Aman":75}
print(min(D))
R={"Aditi":85, "Rajat":65}
R.update(D)
print(D)
P=D
P["Aman"]=82
print(D)
b. Predict the output of the following code:
D={1:"One", 2:"Two", 3:"Three",4:"Four",30:"Thirty"}
L=[]
for K,V in D. items():
if V[0]=="T":
L.append(K)
print(L[::-1]) (3+2)