Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

VELAMMAL VIDHYASHRAM SCHOOLS

Class: XII Session: 2023-24


Computer Science (083)
QUARTERLY EXAMINATION
Date: 09.08.2023 Maximum Marks: 70
Time Allowed: 3 hours

General Instructions:
1. This question paper contains 7 pages
2. Please check this question paper contains 35 questions.
3. The paper is divided into 4 Sections- A, B, C, D and E.
4. Section A, consists of 18 questions (1 to 18). Each question carries 1 Mark.
5. Section B, consists of 7 questions (19 to 25). Each question carries 2 Marks.
6. Section C, consists of 5 questions (26 to 30). Each question carries 3 Marks.
7. Section D, consists of 3 questions (31 to 33). Each question carries 5 Marks.
8. Section E, consists of 2 questions (34 to 35). Each question carries 4 Marks.
9. All programming questions are to be answered using Python Language only.

SECTION-A 19 * 1 = 19

Select the most appropriate option out of the options given for each question. Attempt ALL 18
questions:

1. Suppose a tuple T is declared as T = (10, 12, 43, 39), which of the following is incorrect?
a) print(T[1]) b) T[2] = -29 c) print(max(T)) d) print(len(T))
2. Find the invalid identifier from the following:
a. none b. address c. Name d. pass
3. Which of the following operator cannot be used with string data type?
a. + b. in c. * d. /
4. What is the output of the following code:
T=(100)
print(T*2)
a. Syntax error b. (200,) c. 200 d. (100,100)
5. Evaluate the following expression and identify the correct answer.
16 – (4 + 2) * 5 + 2**3 * 4
a. 54 b. 46 c. 18 d. 32
6. Which statement will merge the contents of both dictionaries?
a. dict_exam.update(dict_result) b. dict_exam + dict_result
c. dict_exam.add(dict_result) d. dict_exam.merge(dict_result)
7. In a stack, if a user tries to remove an element from empty stack it is called _________
a) Underflow b) Empty collection
c) Overflow d) Garbage Collection

8. 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)
9. 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
10. What will be the output of the following code?
x=3
def myfunc():
global x
x+=2
print(x, end=' ')
print(x, end=' ')
myfunc()
print(x, end=' ')
a. 3 3 3
b. 3 4 5
c. 3 3 5
d. 3 5 5
11. What is the output of the below program?
x = 50
def func():
global x
print('x is', x)
x=2
print('Changed global x to', x)
func()
print('Value of x is', x)
a) x is 50 Changed global x to 2 Value of x is 50
b) x is 50 Changed global x to 2 Value of x is 2
c) x is 50 Changed global x to 50 Value of x is 50
d) None of the mentioned
12. Which of the following is the use of id() function in python?
a) Id returns the identity of the object b) Every object doesn’t have a unique id
c) All of the mentioned d) None of the mentioned
13. To read two characters from a file object infile, we use
a) infile.read(2) b) infile.read()
c) infile.readline() d) infile.readlines()
14. The readlines() method returns
a) str b) a list of lines
c) a list of single characters d) a list of integers
15. The correct syntax of seek() is:
(a) file_object.seek(offset [, reference_point])
(b) seek(offset [, reference_point])
(c) seek(offset, file_object)
(d) seek.file_object(offset)
16. Which of the following mode in file opening statement results or generates an error if the file
does not exist?
(a) a+ (b) r+ (c) w+ (d) None of the above
17. Assertion (A):- If the arguments in function call statement match the number and order of
arguments as defined in the function definition, such arguments are called positional
arguments.
Reasoning (R):- During a function call, the argument list first contains default argument(s)
followed by positional argument(s).
(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 but R is False
(d) A is false but R is True

18. Assertion (A): CSV (Comma Separated Values) is a file format for data storage which looks
like a text file.
Reason (R): The information is organized with one record on each line and each field is
separated by comma.
(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 but R is False
(d) A is false but R is True

SECTION – B 7 * 2 = 14
19. Differentiate between mutable and immutable objects in Python language with example.
20. Observe the following Python code very carefully and rewrite it after removing all syntactical
errors with each correction underlined.
DEF execmain():
x = input("Enter a number:")
if (abs(x)=x):
print "You entered a positive number"
else:
x=*-1
print "Number made positive:"x
execmain()
21. Write a user defined function findname(name) where name is an argument in Python to
delete phone number from a dictionary phonebook on the basis of the name, where name is
the key.
OR
Write a small python function that receive two numbers and return their sum, product,
difference
and multiplication and modulo division.
22. What is LIFO data structure? Give any two applications of a stack?
23. Consider a binary file emp.dat having records in the form of dictionary. E.g {eno:1,
name:”Rahul”, sal: 5000} write a python function to display the records of above file for those
employees who get salary between 25000 and 30000
24. The file “New.txt” contains the following:
Better than Heaven or Arcadia
I love thee, o my India!
And thy love I shall give
To every brother nation that lives.
and find the output produce by following code fragment?
f=open(“new.txt”,”r”)
n1=0
for line in f:
n1+=1
print (n1)
25. What are the underflow and overflow conditions?

SECTION – C 5 * 3 = 15

26. A file ‘Admission.dat’ has already been created with the records containing admission
number, name and stream of a number of students as sub-lists of list. Define a function
Delete() to open the file in appropriate mode. Delete the record whose admission number is
input from keyboard.
27. The following figure shows a stack:
T 4

R 3

F 2

Q 1

N 0

Now answer the following questions:


a. Which element will be popped out initially?
b. What will be the value of SP when Q has been popped out?
c. How many elements does the stack contain when SP=1?
28. What is the use of a raise statement? Write a code to accept two numbers and display the
quotient. Appropriate exception should be raised if the user enters the second number
(denominator) as zero (0).
OR
Write a python code to find the size of the file in bytes, number of lines and number of
words.
29. Observe the following Python code carefully and obtain the output, which will appear on the
screen after execution of it.
def div5(n):
if n%5==0:
return n*5
else:
return n+5

def output(m=5):
for i in range(0,m):
print(div5(i),’@’,end=” “)
print(”)
output(7)
output()
output(3)
30. What are the possible outcome(s) expected from the following python code? Also specify
maximum and minimum value, which we can have.
def main():
p = ‘MY PROGRAM’
i=0
while p[i] != ‘R’:
l = random.randint(0,3) + 5
print p[l],’-’,
i += 1
(i) R – P – O – R –
(ii) P – O – R – Y –
(iii) O -R – A – G –
(iv) A- G – R – M –

SECTION – D 2*4=8
Both the questions are compulsory.
31. A binary file “student.dat” has structure [rollno, name, marks].
i. Write a user defined function insertRec() to input data for a student and add to student.dat.
ii. Write a function searchRollNo( r ) in Python which accepts the student’s rollno as
parameter and searches the record in the file “student.dat” and shows the details of student
i.e. rollno, name and marks (if found) otherwise shows the message as ‘No record found’.

32. The functions to perform PUSH and POP operations on a stack are defines below:
def push(st,top, n):
top = top +___ # line 1
________ # line 2
def pop(st, top):
if (top == -1):
print (“Underflow”)
else:
# line 3
top = _______ - 1 # line 4
In the above functions, some places are left blank to be filled with values/ functions.
Answer the following questions:
a. What value/ function will be filled in the blank of Line 1?
top = top +___
b. What value/ function will be filled in the blank of Line 2?
c. What value/ function will be filled in the blank of Line 3?
d. What value/ function will be filled in the blank of Line 41?
top = _____ - 1

OR
Predict the output with respect to the list L=[40,20,30,10,50]
(a) print(len(L))
(b) L.pop() ; print(L)
(c) L.append(70); print(L)
(d) L.sort(); print(L)

SECTION – E 3 * 5 = 15
33. Write a program in Python that defines and calls the following user-defined functions:

1. COURIER_ ADD(): It takes the values from the user and adds the details to a csv
file ‘courier.csv’. Each record consists of a list with field elements as a cid, s_name, Source
and destination to store Courier ID, Sender name, Source and destination address
respectively.
2. COURIER_SEARCH (): Takes the destination as the input and displays all the courier
records going to that destination.
34. Vedika has created a dictionary containing names and marks as key-value pairs of 5 students.
Write a program, with separate user-defined functions to perform the following operations:

1. Push the keys (name of the student) of the dictionary into a stack, where the
corresponding value (marks) is greater than 70.
2. Pop and display the content of the stack.
The dictionary should be as follows:
d={“Ramesh”:58, “Umesh”:78, “Vishal”:90, “Khushi”:60, “Ishika”:95}
Then the output will be: Umesh Vishal Ishika
35. (a) Define Exception?
(b) Compare the following two Python codes shown below and state the output if the
input entered in each case is -6?
CODE 1
import math
num=int(input("Enter a number of whose factorial you want to find"))
print(math.factorial(num))
CODE 2
num=int(input("Enter a number of whose factorial you want to find"))
print(math.factorial(num))

You might also like