June Set-1 MT Xii Cs 2024
June Set-1 MT Xii Cs 2024
June Set-1 MT Xii Cs 2024
dict={“Phy”:94,”Che”:70,”Bio”:82,”Eng”:95}
dict.update({“Che”:72,”Bio”:80})
(a) It will create new dictionary as dict={“Che”:72,”Bio”:80} and old dict will be deleted
dict={“Phy”:94,”Che”:72,”Bio”:80, “Eng”:95}
(d) It will not throw any error but it will not do any changes in dict
L=1,23,'helo',1
SECTION-B (6 x 2 =12M)
11 Rewrite the following Python program after removing all the syntactical errors (if 2
any), underlining each correction:
x=input(“Enter a number”)
if x % 2==0:
else if x<0:
else;
Text = "gmail@com"
L=len(Text) Ntext=""
for i in range(0,L):
if Text[i].isupper():
Ntext=Ntext+Text[i].lower()
elif Text[i].isalpha():
Ntext= Ntext+Text[i].upper()
else:
Ntext=Ntext+'bb'
print(Ntext)
SECTION-C (3 x 3 = 9 M)
if Inp[-1]=='z':
else:
print(Inp)
18 Write a Program in Python, that takes the dictionary and displays the subjects (in upper case) 3
for which marks is greater than or equal to 75.
‘cs’:84}
ENG MATH CS
SECTION-D (1 x 4 = 4 M)
20 a. Write a function in PythonConvert() to replaces elements having even values with its half and 2+2
elements having odd values with twice its value in a list. eg: if the list contains 3,4,5,16,9 then
rearrange the list as 6,2,10,8,18
b. Find the output of following Python code:
def fun(x,y):
if x==0:
return y
else:
return fun(x-1,x+y)
a = fun(4,3)
print(a)
OR
a. Write a function shiftn(L,n), where L is a list of integers and n is an integer. The function 4
should return a list after shifting n number of elements to the left. Example: If the list initially
contains [2, 15, 3, 14, 7, 9, 19, 6, 1, 10] and n=2 then function should return [3, 14, 7, 9, 19,
6, 1, 10, 2, 15] If the list initially contains [2, 15, 3, 14, 7, 9, 19, 6, 1, 10] and n=4 then
function should return [7, 9, 19, 6, 1, 10, 2, 15, 3, 14]