June Set-1 MT Xii Cs 2024

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

PM SHRI KENDRIYA VIDYALAYA NO3 BHUBANESWAR

MONTHLY TEST – JUNE -2024


CLASS XII - COMPUTER SCIENCE (083)
Max. Time: 1 ½ Hours Max. Marks: 35 M

SECTION-A (10 x1=10M)


1 State True or False. 1
“Identifiers are names used to identify a variable, function.
2 What will be the output of the following statement? 1
10> 5and 7> 12or not 18>3

3 What will be the output of the following Python Code? 1


ANIMAL={"dog":10,"tiger":5,"elephant":15,"Cow":3}
print("Tiger" not in ANIMAL)
(a) True (b) False (c) Error (d) None

4 What will the following code do? 1

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

(b) It will throw an error as dictionary cannot be updated

(c) It will simply update the dictionary as

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

5 Identify the data type of L where 1

L=1,23,'helo',1

a)list b) dictionary c) tuple d) string

6 Given is a Python list declaration : 1


listofnames=["Aman","Ankit","Ashish","Rajan","Rajat"]
Write the output of:
print(listofnames[-1:-4:-1])
(a) ['Rajat', 'Rajan', 'Ashish'] (b) 'Ashish', 'Rajan', 'Rajat'] (c) ['Rajat', 'Rajan']
(d) None
7 What is the default return value for a function that does not return any value 1
explicitly?
(a)None (b) int (c) double (d) null
8 What are the possible output(s) expected from the following code? 1
import random
SIDES=("EAST","WEST","NORTH","SOUTH")
OUT=""
N=random.randint(1,3)
for i in range(N,0,-1):
OUT=OUT+SIDES[i]
print(OUT)
(a) SOUTHNORTH (b) SOUTHNORTHWEST (c) SOUTH (d) EAST WESTNORTH

9 Which of the following function header is Correct: 1


(a) def fun(x=1,y) (b) def fun(x=1,y,z=2)
(c) def fun(x=1,y=1,z=2) (d) def fun(x=1,y=1,z=2,w)

10 Evaluate:- not false and true or false and true 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:

print( x, “is even”)

else if x<0:

print( x, “should be positive”)

else;

print( x “is odd”)

12 Write the ouput of the following code:- 2

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)

13 Write the Python statement for each of the following tasks: 2


(a)to delete the element from beginning of the list ‘L’
(b)to insert the elements of list ‘L1’ as individual elements in list ‘L’
14 Find the output 2
L = [10,19,45,77,10,22,2]
i) L[3:5] ii) L[: : -2]

15 What will be the output of the following code? 2


def check(L, a=10):
for x in range(1, len(L)):
if L[x]%a == 0:
L[x-1] = L[x]-1
for z in range(0,len(L),2):
print(L[z], ' ' , L[z+1])
check([25, 40, 15, 25], 5)
16 Given is a Python string declaration: 2
myexam="RussiaUkrain"
Write the output of :
print(myexam[-2:2:-2])
(b) Write the output of the code given below:
D1={"sname":"Aman","age":26}
D1['age']=27
D1['address']="Delhi"
print(D1.items())

SECTION-C (3 x 3 = 9 M)

17 What will be the output of the following Python code? 3

Inp = input("Please enter a string:")

while len(Inp) <= 4:

if Inp[-1]=='z':

Inp= Inp [0:3] + 'c'

elif 'a' in Inp:

Inp =Inp[0] + 'bb'

elif not int(Inp[0]):


Inp='1' + Inp [1:]+'z'

else:

Inp = Inp + ‘*’

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.

For example, consider the following dictionary

marks = {‘eng’:78, ‘phy’:69, ‘chem’:74, ‘math’:75,

‘cs’:84}

The output should be:

ENG MATH CS

19 Write a program to find out double of the given list? 3

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]

You might also like