You are on page 1of 13

D.A.V.

SCHOOL
(Affiliated to C.B.S.E. New Delhi)
Sree Nandeeswarar Campus, Adambakkam, Chennai – 600 088
MCQ Test Series – 1 2023-2024
Computer Science
Maximum Marks:55 Time Allowed: 60 Minutes

Q.NO. Section-A

1 i) Name the module which will be needed to use the function max( ) : -
A. math B. random C. stat D. No module required
ii) Which command we can use to remove ?
string “hello” from list1, Given, list1=[“hello”]
A. list1.remove(“hello”) B. list1.pop(list1.index('hello'))
C. Both a & b D. None of these
2 i) Which of the following functions will return the key, value pairs of a dictionary?
A. keys() B. values() C. items() D. all of these
ii) A variable declared/defined outside a specific function is known as: -
A .Local variable B. Specific variable
C. Global Variable D. None of the above
3 i) The return type of the input() function is
A. String B. integer C. list D. tuple
ii) Choose correct answer
def fun1(num):
return num+5
print(fun1(5))
print(num)
A. print value 10 B. print value 5 C.Name Error D.25
4 i) Which of the following operator cannot be used with string data type?
A. + B. in C.* D./
i) Which of the following is not a function of tuple?
A. update() B. index( ) C.len( ) D.count( )

5 i) Consider a tuple tup1=(10,15,25,30).Identify the statement that will result in an error.


A.print(tup1[2]) B.tup1[2] =20 C.print(min(tup1)) D.print(len(tup1))
ii) What will be the output of below Python code?
tupl=([2,3],"abc",0,9)
tupl[0][1]=1
print(tupl)
A. ([2,3],"abc",0,9) B. ([1,3],"abc",0,9) C.([2,1],"abc",0,9) D.Error
6. i)Consider a declaration L=(1,'Python','3.14').Which of the following
represents the data type of L?
A.list B. tuple C.dictionary D.string
ii) What will be the output of the following code segment?
l=['A','a','Aa','aA']
print(max(l))
A. 'aA' B. 'A', C. 'a' D. 'Aa'
7. i) Given a Tuple tup1=(10,20,30,40,50, 60,70, 80, 90).
What will be the output of print (tup1 [3:7:2])?
A. (40,50,60,70,80) B.(40,50,60,70) C. [40,60] D. (40,60)
ii) Which of the following is correctly evaluated for this function?
pow(x,y,z)
A.(x**y) / z B. (x / y) * z C.(x**y) % z D.(x / y) / z

1
8 i) Which command can we use to insert 5 at the third position in list1?
A.list1.insert(3, 5) B.list1.insert(2, 5) C.list1.add(3, 5) D.list1.append(3, 5)

ii) What is the length of the given tuple?


t1=(1,2,(3,4,5))
A. 1 B. 2 C. 3 D.4
9 i) What will be the output of the following code segment?
list1 =['Red', 'Green', 'Blue', 'Cyan', 'Magenta', 'Yellow', 'Black']
print(list1[-4:0:-1])
A. ['Cyan', 'Blue', 'Green', 'Red'] B. []
C. ['Cyan', 'Blue', 'Green'] D. ['Cyan', 'Magenta', 'Yellow', 'Black']

ii) Which of the following can be used to delete item(s) from a dictionary?
A. del statement B. get()
C. getitem() D. all of these
10 i) Find the invalid identifier from the following
A.none B. address C. Name D. pass
ii) Choose odd one out : -
A.except B.with C.Import D.else
11 i) Which of the following is the correct way to call a function?
A. my_func() B.def my_func() C. return my_func D.call my_func()
ii) What keyword would you use to add an alternative condition to an if statement?
A. else if B. elseif C. elif D.None of the above
12
i) Which line of code produces an error?

A. "one" +'two' B. 1+ 2 C. "one"+ "2" D. '1'+2


ii ) Which of the following function will return the total number of characters in a string.
A. count() B. index() C. len( ) D. all of these

13 i) Choose the correct option with respect to Python


A. Both tuples and lists are immutable. B. Tuples are immutable while lists are mutable.
C. Both tuples and lists are mutable. D. Tuples are mutable while lists are immutable.

ii) Write the output of the following.


a=(23,34,65,20,5)
print(a[0]+A.index(5))
A. 28 B. 29 C. 27 D.26
14 i) What would the following code print?
d = {'spring': 'autumn', "autumn": "fall", "fall":"spring"}
print (d["autumn"])
A. Autumn B. fall C. spring D.Error
ii) What is printed by the following statements ?
D1 = {"cat":17, "dog":6, "elephant":23, "bear":20}
print (20 in D1)
A. True B. False C.Error D.None

15 i) Which of the following function header is correct?


A. def cal_si(p=100,r,t=2) B. def cal_si(p=100,r=8,t)
C. def cal_si(p,r=8,t) D. def cal_si(p,r=8,t=2)

2ii) What is the return type of function id?


A. Int B. float C. bool D. dict

2
16 i) Write the output of the following:

def fun3(num1,num2):
for x in range(num1,num2):
if x%4==0:
print(x,end=' ')
fun3(10,20)
A. 10 12 16 20 B. 12 16 C. 12 16 20 D.16
ii) Write the output of the following:
a=(1, 2, 3, 2, 3, 4, 5)
print(min(a) + max(a) + A.count(2))
A. 13 B. 6 C.8 D.Error
17 i) What is printed by the following statements?
D1 = {"cat":17, "dog":6, "elephant":23, "bear":20}
print ("dog" in D1)
A. True B. False C. Error D. None
ii) Identify correct output
def fun3(a,b,c):
return a+1,b+2,c+3
t=fun3(10,20,30)
print(t)
A.11,22,33 B.11 22 33 C.(11, 22, 33) D.None
18 i) Which of the following creates a tuple?
A. tuple1=("a","b") B. tuple1[2]=("a","b") C. tuple1=(5)*2 D.None of the above
ii) What will be the result of the following code?
dict = {"Jo" : 1, "Ra" : 2}
dict.update({"Ph":2})
print (dict)
A. {"Jo":1,"Ra" :2, "Ph" : 2} B. {"Jo":1,"Ra":2} C. {"Jo":1,"Ph" :2} D. Error

19 i) Choose correct output for the following code


def check(x,y):
if x != y:
return x+5
else:
return y+10
print(check(10,5))
A.15 B.20 C.5 D.10
ii)Which of the following declaration is incorrect in python language?
A. xyzp = 5,000,000 B. x y z p = 5000 6000 7000 8000
C.x,y,z,p = 5000, 6000, 7000, 8000 D. x_y_z_p = 5,000,000
20 i) Which of the following components are part of a function header in Python?
A. FunctionName B. ReturnStatement C. ParameterList D.Both a and c
ii) What is the output of this expression, 3*1**3?
A. 27 B. 9 C. 3 D. 1
21 i) What is the output of following code:
T=(100)
print(T*2)
A. Syntax error B.(200,) C.200 D.(100,100)
ii) What is the output of following code:
a=(1,2,3)
a*3
s=(a,a,a)
print(s)
A. ((1, 2, 3), (1, 2, 3), (1, 2, 3)) B. (1, 2, 3, 1, 2, 3, 1, 2, 3)
C.(123,123,123) D.NONE
3
22 i) What is the output of the following code?
my_dict={}
my_dict[(1,3,5)]=19
my_dict[(2,4,6)]=29
s=0
for k in my_dict:
s+=my_dict[k]
print(my_dict,s)
A. {(1, 3, 5),19, (2, 4, 6),29} B. {(1, 3, 5),19:}, {(2, 4, 6),29:} 48
C. {(1, 3, 5): 19, (2, 4, 6): 29} 48 D.NONE

ii) d = {"DAV-1":40, "DAV-2":45}


To obtain the number of entries in dictionary which command do we use?
A. D.size() B. len(d) C.size(d) D.len()
23 i) Identify the output of the following Python statements.
x=[[10.0,11.0,12.0],[13.0,14.0,15.0]]
y=x[1][2]
print(y)

A.12.0 B.13.0 C.14.0 D.15.0


ii) What is the output of the code shown below?
[ord(ch) for ch in 'abc']
A. A. [97, 98, 99] B. [‘97’, ‘98’, ‘99’] C. [65, 66, 67] D. Error
24 i) Identify the output of the following Python statements.

x=2
whilex<9:
print(x, end='')
x=x+1
A.12345678 B.123456789 C.2345678 D.23456789

ii) Write the list comprehension for producing a list of numbers between 1 and 20 that are even numbers.

A. [for x in range(1,20) if x%2==0] B. [ for x in range(0,20) if x%2==0]


C. [x for x in range(2,21) if x%2=0] D. [x for x in range(1,20) if x%2==0]
25 i) Identify the output of the following Python statements.
b=1
for a in range(1,10,2):
b+=a+2
print(b)
A. 31 B.33 C. 36 D.39

ii) What is the output of the following?

x = 'abcd'
for i in range(len(x)):
print(I,end=’ ‘)

A. a b c d B. 0 1 2 3 C. error D. 1 2 3 4

4
26 i) Which one of the following is the default extension of a Pythonfile?
A. .exe B. .p++ C. .py D. .p
Ii) Choose correct statement .
A. Default values overrides the values passed by the user
B. Default argument are declared before the positional argument
C. Values passed by user overrides the default values
D. All are correct
27 i) Which of the following symbol is used in Python for single line comment?
A. / B. /* C. // D. #
ii) Consider the following code and choose the correct answer .
def nameage(name=”kishan”, age=20):
return age,name
t=nameage(20,”kishan”)
print(t[1])
B. Kishan B. 20 C. (kishan, 20) D. (20,kishan)
28 i) What does strip() function do?
A. Removes the trailing or leading spaces, if any. B. Deletes the file
C.Remove the file object D. Removes all the spaces between words
ii) What will be the output of below Python code?
tuple1=(5,1,7,6,2)
tuple1.pop(2)
print(tuple1)
A. (5,1,6,2) B. (5,1,7,6) C. (5,1,7,6,2) D. Attribute error
29 i) Which of these about a dictionary is false?
A. The values of a dictionary can be accessed using keys
B. The keys of a dictionary can be accessed using values
C. Dictionaries aren’t ordered
D. Dictionaries are mutable
ii) Dictionaries are ____ set of elements
A. Sorted B. ordered C. unordered D.random
30 i) Predict the output of the following code
def func1(list1):
for x in list1:
print(x.lower(),end='#')
func1(['New','Dehli'])
A. [New,Dehli] B. new#dehli# C. newdehli# D. New#Dehli#
ii) Identify correct output for the followingcode.

def fun4(a,b=100):
total=a+b
print(total)
fun4(50,20)
A.100 B. 120 C. 150 D. 70
31 What will be the output of the following code?
value = 63
def display(N):
global value
value = 36
if N%7==0:
value = value + N
else:
value = value - N
print(value, end="#")
display(20)
5
print(value)

A. 63#36 B. 16#63 C. 63#16 D. NONE


32 What will be the output of the following code?
import random
List=["Delhi","Mumbai","Chennai","Kolkata"]
for y in range(4):
x = random.randint(1,3)
print(List[x],end="#")
A. Delhi#Mumbai#Chennai#Kolkata#
B. Mumbai#Chennai#Kolkata#Mumbai#
C. Mumbai#Mumbai#Mumbai #Delhi#
D.Mumbai#Mumbai#Chennai#Mumbai
33 What will be the output of the following code?
def ChangeVal(M,N):
for i in range(N):
if M[i]%5 == 0:
M[i]//=5
if M[i]%3 == 0:
M[i]//=3
L = [12,25,16,75]
ChangeVal(L,4)
for i in L:
print(i,end="#")

A. 5#16#5# B. 4#16#5# C. 4#5#16#5# D. 4#5#16

34 Which is not a possible output from the given code?

import random
List=["12A","12B","12C","12D"]
for y in range(4):
x = random.randint(1,3)
print(List[x],end="#")
A. 12D#12B#12D#12D# B. 12C#12D#12B#12B#
C. 12D#12B#12B#12C# D. 12A#12B#12B#12C#

35 What will be the output of the following code?


def my_func(var1=20, var2=15):
var1+=10
var2 = var2-10
return var1+var2
print(my_func(50),my_func())
A. 65 35 B. 33 65 C. (35,65) D. (33,65)

6
36 i) What is the output of the code shown below?

l1=[1,2,3]
l2=[4,5,6]
l3=[7,8,9]
for x, y, z in zip(l1, l2, l3):
print(x, y, z)
A) 1 4 7 B) (1 4 7) C) [(1, 4, 7), (2, 5, 8), (3, 6, 9)] D) Error
258 (2 5 8)
369 (3 6 9)

ii) What is the output of the following?

a = [0, 1, 2, 3]
for a[0] in a:
print(a[0],end=” ”)
A. 0 1 2 3 B. 0 1 2 2 C. 3 3 3 3 D.error

37 i) What will be the output of the following Python code?

def add (num1, num2):


sum=num1+num2
sum = add(20,30)
print(sum)
A. 50 B. 0 C. Null D. None

ii) What is the output of the following code?

x=12
def f1(a,b=x):
print(a,b)
x=15
f1(4)
A. Error B. 12 4 C.4 12 D. 4 15
38 i) Evaluate the following expression and identify the correct answer.
16-(4+2) *5 + 2**3*4
A. 54 B. 46 C. 18 D. 32
ii) Evaluate the following expression and identify the correct answer.
7-23%2*12+6
A. 1 B.18 C.17 D.-5
39 What will be the output of the following code?
def my_func(var1=20, var2=15):
var1+=10
var2 = var2-10
return var1+var2
print(my_func(50),my_func())
A. 65 35 B. 33 65 C. (35,65) D. (33,65)
40 i) What is the output of the following piece of code?

a={1:"A",2:"B",3:"C"}
print(a.get(1,4))
A. 1 B. A C.4 D.Invalid syntax for get method

7
ii)
a={1:"A",2:"B",3:"C"}
b={4:"D",5:"E"}
a.update(b)
print(a)
A. {1: ‘A’, 2: ‘B’, 3: ‘C’} B. Method update() doesn’t exist for dictionaries
C. {1: ‘A’, 2: ‘B’, 3: ‘C’, 4: ‘D’, 5: ‘E’} D.{4: ‘D’, 5: ‘E’}

41 What will be the output of the following code?


>>> tup1 = (1,2,[1,2],3,4,[6.7,8])
>>> tup1[5][0]-=3.56
>>> print(tup1)

A. (1, 2, [1, 2], 4, [3.14, 8])


B. (1, 2, [1, 2], 3, 4, [3.14, 8])
C. (1, 2, [1, 2], 3, 4, [3.1, 8])
D.Error Message
42 Text1="CBSE TERM#1 2021"
Text2=""
I=0
while I<len(Text1):
if Text1[I]>="0" and Text1[I]<="9":
Val=int(Text1[I])
Val=Val+1
Text2=Text2+str(Val)
elif Text1[1]>="A" and Text1[I]<="Z":
Text2=Text2+(Text1[I+1])
else:
Text2=Text2+"*"
I=I+1
print(Text2)
A. BSE TERM# B. BSE TERM# C. BSE TERM#1223132 D. BSE TERM
43 Find the output of the following code:
Name="All The BEST!"
R=""
for x in range(len(Name)):
if Name[x].isupper():
R=R+Name[x].lower()
elif Name[x].islower():
R=R+Name[x].upper()
elif Name[x].isdigit():
R=R+Name[x-1]
else:
R=R+"#"
print(R)
A. ALL#THE#BEST# B. aLL#tHE#best# C. aLL#tHEbest# D. NONE
44 Find and write the output of the following python code:
Msg1='CBSE BOARD- 2021'
Msg2='EXAM'
Msg3=''
for I in range(0,len(Msg2)+1):
8
if Msg1[I]>='A' and Msg1[I]<='M':
Msg3=Msg3+Msg1[I]
elif Msg1[I]>='N' and Msg1[I]<='Z':
Msg3=Msg3+Msg2[I]
else:
Msg3=Msg3+'*'
print(Msg3)
A. CBAE* B. CBSE* C. CBSE*EXAM D.NONE
45 def Alter(P=13,Q=31):
P=P*Q
Q=P/Q
print(P,"#",Q)
return Q
A=20
B=30
A=Alter(A,B)
print(A,"$",B)
B=Alter(B)
print(A,"$",B)
A=Alter(A)
print(A,"$",B)
A. B.
600 # 20.0 600 # 20.0
20.0 $ 30 20.0 $ 30
930 # 30.0 20.0 $ 30.0
20.0 $ 30.0 620.0 # 20.0
20.0 $ 30.0 20.0 $ 30.0
>>> >>>

C. D.NONE
600 # 20.0
20.0 $ 30
930 # 30.0
20.0 $ 30.0
620.0 # 20.0
20.0 $ 30.0
>>>

46 Identify the list at the end of third pass of insertion sort for the given list of numbers which gets sorted in
ascending order.

L=[16,-16,86,0,24,14]
A) [-16, 0, 86, 16, 24, 14] B) [-16, 0, 14, 16, 24, 86]
C) [-16, 0, 16, 86, 24, 14] D) NONE

47 What will be the output of the following code?


x=3
def myfunc():
global x
x+=2

9
print(x,end='')
print(x, end=' ')
myfunc()
print(x,end='')
A.3 33 B.3 45 C.3 35 D.3 55
48 i) The time complexity of the bubble sort and insertion sort technique is ____
A)1 B) 2 since it has two loops
2
c) n D) NONE

ii) Insertion sort is _____ time algorithm.


a.Constant B. Linear C. Quadratic D.NONE
49 i) When two elements map to the same slot in the hash table, it is called _____
A)Hashing B)Collision C)Time complexity D) NONE
ii) What is the order of resolving scope of a name in a Python program?
(L:Local namespace,E:Enclosing namespace,B:Built-In Namespace,G:Global namespace)
A .B G E L B. L E G B C.G E B L D.L B E G

50 i) Identify the list at the end of fourth pass of bubble sort for the given list of numbers which gets sorted in
ascending order.
L=[12,-13,4,6,24,100]
A) [-13, 12, 4, 6, 24, 100] B) [-13, 4, 12, 6, 24, 100]
C) [-13, 4, 6, 12, 24, 100] D) NONE

ii) Find the output:


x = ('key1', 'key2', 'key3')
thisdict = dict.fromkeys(x)
print(thisdict)
A. {‘key1’: 0, ‘key2’: 1, ‘key3’: 2} B. {‘key1’: 1, ‘key2’:2, ‘key3’: 3}
C. {‘key1’: None, ‘key2’: None, ‘key3’: None} D. {‘key1’: ‘key1’, ‘key2’: ‘key2’, ‘key3’: ‘key3’}
51 i) Find and write the output of the following python code:
def makenew(mystr):
newstr=""
count=0
for i in mystr:
if count%2!=0:
newstr=newstr+str(count)
elif i.islower():
newstr=newstr+i.upper()
else:
newstr=newstr+i
count+=1
newstr=newstr+mystr[:1]
print("The new string is :", newstr)
makenew("BEST wishes")
A. The new string is : BB1B1SB3B B5BIB7BHB9BSB
B. The new string is : BB1BSB3B B5BIB7BHB9BSB
C. The new string is : BB1BS1B3B B5BIB7BHB9BSB
D. None

10
ii) Find and write the output of the following python code:
NAME="VaRiAbLe"
N=""
for x in range(len(NAME)):
if NAME[x].islower():
N=N+NAME[x].upper()
elif NAME[x].lower():
if x%2==0:
N=N+NAME[x].lower()
else:
N=N+NAME[x-1]
print(N)
A. vArIaBlE B. VaRiAbLe C. VARIABLE D. none

52 i) What possible output(s) are expected to be displayed on screen at the time of execution of the
program from the following Python code?Also specify the minimum values that can be assigned to
each
of the variables BEGIN and LAST.
import random
VALUES=[40,50,60,70,80];
BEGIN=random.randint(1,3)
LAST=random.randint(BEGIN,4)
for I in range(BEGIN,LAST+1):
print(VALUES[I],"-",end="")
A. 60 -70 -80 B. 60 -70 -80 – C. 60 _70 -80 – D.None

ii) Find the output:


def Revert(Num,Last=4):
if Last%4==0:
Last=Last+1
else:
Last=Last-1
for C in range(1,Last+1):
Num+=C
print(Num)
A,B=30,6
Revert(A,B)
B=B-1
Revert(B)

A. 45 B. 20 C. 45 20 D.NONE
20 45
53 i)
def C2F(c):
return c * 9/5 + 32
print (C2F(100))
print (C2F(0))
A. 212 B.314 C.567 D. None of the mentioned
32 24 98
ii)
def sum(*args):
"""This is the sample text"""
r=0

11
for i in args:
r+=i
return r
print (sum.__doc__)
print (sum(1, 2, 3))
print (sum(1, 2, 3, 4, 5))
A. 6 B. 6 C.123 D. None of the above
15 100 12345
54 i) What possible output(s) are expected to be displayed on screen at the time of execution of the
program from the following Python code?Also specify the minimum values that can be assigned to
each
of the variables Start and End.
import random
VAL=[60,50,40,30,20,10]
Start=random.randint(1,3)
End=random.randint(Start,4)
for I in range(Start,End+1):
print(VAL[I],"*",end="")
a. 30 *20 b. 20 30 * c. 20 *30 * d. 30 *20 *

ii)
def Mycode(Msg,C):
M=""
for i in range(len(Msg)):
if"B"<=Msg[i]<="H":
M=M+Msg[i].lower();
elif Msg[i]=="A" or Msg[i]=="a":
M=M+C;
elif i%2==0:
M=M+Msg[i].upper()
else:
M=M+Msg[i-1]
print(M)
text="LOADER";
Mycode(text,"#")

A. B.
L L
LL LL
LL# LL#
LL#d LL#d
LL#de LL#de
LL#deE

C. D.NONE
LL
LL#
LL#d
LL#de
LL#deE

12
55 i) Write the output:

def sample(**args):
try:
for i in args:
i=i*3
args[i]="new"
print(args,end='')
except:
print("\ncompleted")
sample(x=10,y=20,z=10)

ii) Write the output:

def sample1(*s):
print(sum(s))
sample1(2,-3,4)
sample1(4,5)
sample1(56,3,-12)

13

You might also like