MODEL EXAM SAMPLE PAPER, JANUARY 2024
COMPUTER SCIENCE
General instructions:
• The question paper contains 35 questions.
• The paper is divided into 4 Sections- A, B, C, D and E.
• Section A consists of 18 questions (1 to 18). Each question carries 1 Mark.
• Section B consists of 7 questions (19 to 25). Each question carries 2 Marks.
• Section C consists of 5 questions (26 to 30). Each question carries 3 Marks.
• Section D consists of 2 questions (31 to 32). Each question carries 4 Marks.
• Section E consists of 3 questions (33 to 35). Each question carries 5 Marks.
• All programming questions are to be answered using Python Language only.
SECTION A [18*1=18]
1 What is printed when the following code is executed? [1]
tup = ('30', '3', '2', '8')
print(sorted(tup, reverse = True))
a) ['2', '3', '30', '8'] b)['8', '30', '3', '2'] c) ['30', '8', '3', '2'] d) Error
2 Write the output of the following [1]
a=(23,34,65,20,5)
print(a[0]+a.index(5))
a) 28 b) 29 c) 27 d) 26
3 Which of the following methods returns a new dictionary with the given sequence of [1]
elements as the dictionary's keys?
a) sorted() b) fromkeys() c) update() d) items()
4 Which of the following functions returns the ASCII code for a specified character? [1]
a) ASCII() b) asc() c) ord() d) code()
5 Which of the following is true about the List data type in Python? [1]
a) A List is a Sequence data type
b) A List is immutable
c) A List cannot have elements of different data types
d) All of the above
6 Find the output : [1]
a=(23,34,65,20,5)
s=0
for i in a:
if i%2==0:
s=s+a[i]
print(s)
a) 54 b) 93 c) 94 d) Error
7 Write the output of the following [1]
s="blog"
for i in range(-1,-len(s),-1):
print(s[i],end="$")
a) g$o$l$b$ b) g$o$l$ c) g$o$ d) Error
8 Which of the following is an invalid variable? [1]
a) my_string_1 b) 1st_string c) _my_string d) My_string
9 Dictionaries in Python are _________________. [1]
a) Mutable data type
b) Non-mutable data type
c) Mapping data type
d) Both a and c
10 What is the output of print(0.1 + 0.2 == 0.3)? [1]
a) True b) False c) Machine dependent d) Error
11 x = 'abcd' [1]
for i in x:
x = 'a'
print(x, end="")
The output of the code is _______.
a) a b) aaaa c) abcd d) abcd abcd abcd …
12 A ______________ statement skips the rest of the loop and jumps over to the statement [1]
following the loop.
a) Break b) continue c) if else d) pass
13 What does the following code print? [1]
output = ""
x = -5
while x < 0:
x=x+1
output = output + str(x) + " "
print(output)
a) 5 4 3 2 1 b) -4 -3 -2 -1 0 c) -5 -4 -3 -2 -1 d) 4 3 2 1
14 Which of the following is not a valid for loop in Python? [1]
a) for(i=0; i<n; i++) b) for i in range(0,5): c) for i in range(0,5) d) for i in range(5)
15 What is the output of the following code? [1]
sampleList = [10, 20, 30, 40]
del sampleList[0:6]
print(sampleList)
a) [] b) list index out of range c) [10, 20] d) Error
16 If t =(20,56,89,54,32,12), then what will be the output for print(t[4:-1])? [1]
a) (20,56,89,54,32,) b) (32,) c) (12,32,) d) (56,89,54,32,12)
Q17 and Q18 are ASSERTION and REASONING-based questions. Mark the correct choice as
a) Both A and R are True, and R is the correct explanation for A
b) Both A and R are True, and R is not the correct explanation for A
c) A is True and R is False
d) A is False but R is True
17 Assertion(A): List is an immutable data type [1]
Reasoning(R): When an attempt is made to update the value of an immutable variable, the old
variable is destroyed and a new variable is created by the same name in memory.
18 Assertion(A): The keys of the dictionaries must be unique. [1]
Reason(R): The keys of a dictionary can be accessed using values.
SECTION B [2*7=14]
19 Rewrite the code after correcting the errors. Underline the corrected code.
[2]
l=[10,20,30,40]
for i in range(len(l))
if (i%2=0):
print(l(i),end="#")
Else:
print(l[i])
20 Write a program to print the following pattern using nested for loop. [2]
P
PY
PYT
PYTH
PYTHO
PYTHON
21 Find the output: [2]
str1=list("Oob@sch*")
for i in range(0,len(str1)):
if i==5:
str1[i]=str1[i]*2
elif str1[i].isupper( ):
str1[i]=str1[i]*3
else:
str1[i]="A"
print(str1)
22 Specify two methods to delete the key-value pair for key="cow" in the dictionary. [2]
d={"lion":"wild","tiger":"wild","cat":"domestic","cow":"domestic"}
23 Write a program that takes a value and checks whether it is part of the given dictionary or not. [2]
If yes, the program should print the corresponding key, otherwise print an error message.
24 Write a program that reads a string and changes the case of uppercase to lowercase and vice [2]
versa, space to # and digits to $.
25 Consider the following Dictionary [2]
D= {“How”:22,” was”:23,” your ”:24, “exam”:25}.
Evaluate each statement starting with the same value of the dictionary D and write the output
for the statement print(D)
a) D[“How”]=D[“was”]+100
b) D.setdefault(“was”,200)
c) D.pop()
SECTION C [3*5=15]
26 Write a program that reads a string and a substring. [3]
a) It should display the number of occurrences of the given substring in the string.
b) Display the string in reverse order- one character per line
27 a) Evaluate the following expression: [3]
48 % 3 ** 3//5 +2**6
b) What will be the output of the following code snippet?
my_dict = {}
my_dict[1] = 1
my_dict['1'] = 2
my_dict[1.0] = my_dict[1]+1
print(my_dict)
count=0
for k in my_dict:
count += my_dict[k]
print (sum)
28 Write a program to [3]
a) Consider the lists given below. Add the elements of the lists to create a new list.
a=[10,20,30,40,50] b=[20,30,40,50,60]
#Output: c=[30,50,70,90,110]
b) From the new list, display the elements divisible by 5.
29 a) Write a program that asks for the number of elements (N) to be appended in the tuple, input [3]
the N elements, and print the tuple.
b) The program should also display the mean of the elements in the tuple. (without using the
mean function)
30 Write a program to increment the elements of a list with a number. [3]
Enter a list: [1, 2, 3, 4, 5]
Existing list is: [1, 2, 3, 4, 5]
Enter a number: 10
List after increment: [11, 12, 13, 14, 15]
SECTION D [2*4=8]
31 Consider the given list:
L=[“apple”, ”orange”, ”pear”, ”strawberry”, “pineapple”] [2]
a) remove all strings starting with the letter p and display the new list.
[2]
b) display the names which has more than 5 letters in it.
32 Use the code given below to answer the questions based on it: [4]
inp1str=input(“enter string of digit:”)
inp2str=input(“enter string of digits”)
if len(inp1str)>len(inp2str):
small=inp2str
large=inp1str
else:
small=inp1str
large=inp2str
newStr=” ”
for element in small :
result=int(element)+int(large[0])
newStr=newStr + str(result)
large=large[1:]
print(len(newStr)) --------line 1
print(newStr) ---------line 2
print(large) ---------line 3
print(small) --------line 4
a) Given a first input of 12345 and a second input of 246, what result is produced by line 1?
b) Given a first input of 12345 and a second input of 246, what result is produced by line 2?
c) Given a first input of 123 and a second input of 4567, what result is produced by line 3?
d) Given a first input of 123 and a second input of 4567, what result is produced by line 4?
SECTION E [3*5=15]
33 Create two lists of n numbers. [5]
a) Accept user inputs to create the lists.
b) Find the sum of the even-indexed elements of list 1 with the odd-indexed elements of list 2.
c) Display the common elements in both lists.
d) If the new list is L, what change does the code L[::2]=10,20,30 make in list L?
34 Write a menu-driven program to create a tuple and perform the following [5]
a) Accept 10 user input to create a tuple
b) Receive the index and return the corresponding value.
c) Display the even numbers and odd numbers in separate tuples
35 Write a Python program [5]
a) to input ‘n’ names and phone numbers to store them in a dictionary.
b) input a name and print the phone number of the particular name. If the name is not present
leave an appropriate message.
c) Display all the names starting with the letter V.