Computer Science Class Xii Question Paper Hy Exam 2024-25
Computer Science Class Xii Question Paper Hy Exam 2024-25
values=[]
for i in range(1,4):
values.append(i)
print(values)
7 Write the missing statement to complete the following code: 1
file = open("example.txt", "r")
data = file.read(100)
_________________ #Move the file pointer to the beginning of the
file
next_data = file.read(50)
file.close()
8 State whether the following statement is True or False: 1
An exception may be raised even if the program is syntactically
correct.
9 Which switching method offers a dedicated transmission channel? 1
(a)Packet switching (b)Circuit switching (c)Message switching
(d)None of these
10 What will be the output of the following code? 1
c = 10
def add():
global c
c=c+2
print(c,end='#')
add()
c=15
print(c,end='%')
(a) 12%15# (b) 15#12% (c) 12#15% (d) 12%15#
11 Which of the following functions changes the position of file pointer 1
and returns its new position?
(a) flush() (b) tell() (c) seek() (d) offset()
12 Which protocol is used to transfer files over the Internet? 1
(a) HTTP (b) FTP (c)PPP (d)HTTPS
13 Which network device is used to connect two networks that use 1
different protocols?
(a) Modem (b) Gateway (c)Switch (d)Repeater
14 Data structure stack is also known as ________________list. 1
(a)First in First out (b)First in last out (c)Last in first out
(d)All of these
15 The readlines( ) method returns: 1
(a)str (b)a list of lines (c)tuple (d)dictionary
16 The collection of modules and packages that together cater to a 1
3
Identify one mutable object and one immutable object from the
following:
(1,2), [1,2], {1:1,2:2}, ‘123’
24 Give two examples of each of the following: 2
(I) Membership operators (II) Identity operators
25 List one advantage and one disadvantage of star topology. 2
26 Write the output of the code given below: 2
p=5
def sum(q,r = 2):
global p
p = r + q**2
print(p,end= ‘#’)
a=10
b=5
sum(a,b)
sum(r = 5, q = 1)
27 A program having multiple functions is considered better designed 2
than a program without any functions. Why?
28 (a) Write the full forms of the following: (i) SMTP (ii) PPP 2
(b) What is the use of TCP/IP?
Section-C ( 3 x 3 = 9 Marks)
29 Write a Python function that finds and displays all the words longer 3
than 5 characters from a text file "Words.txt"
30 A list contains following record of a customer: [Customer_name, 3
Phone_number, City] Write the following user defined functions to
perform given operations on the stack named ‘status’:
(i)Push_element() - To Push an object containing name and Phone
number of customers who live in Goa to the stack
(ii)Pop_element() - To Pop the objects from the stack and display
them. Also, display “Stack Empty” when there are no elements in the
stack. For example: If the lists of customer details are:
[“Gurdas”, “99999999999”,”Goa”]
[“Julee”, “8888888888”,”Mumbai”]
[“Murugan”,”77777777777”,”Cochin”]
[“Ashmit”, “1010101010”,”Goa”]
The stack should contain
[“Ashmit”,”1010101010”]
[“Gurdas”,”9999999999”]
The output should be:
[“Ashmit”,”1010101010”]
[“Gurdas”,”9999999999”]
5
Stack Empty
31 Write a method in Python to read lines from a text file Mynotex.txt 3
and display those lines, which are starting with an alphabet ‘K’.
SECTION D (4 X 4 = 16 Marks)
32 When is NameError exception raised in Python? 4
Give an example code to handle NameError? The code should
display the message "Some name is not defined" in case of
NameError exception, and the message "Some error occurred" in case
of any other exception.
33 Ranjan Kumar of class 12 is writing a program to create a CSV file 4
“user.csv”
which will contain user name and password for some entries. He has
written
the following code. As a programmer, help him to successfully
execute the
given task.
import _____________ # Line 1
def addCsvFile(UserName,PassWord):
# to write / add data into the CSV file
f=open(' user.csv','________') # Line 2
newFileWriter = csv.writer(f)
newFileWriter.writerow([UserName,PassWord])
f.close()
#csv file reading code
def readCsvFile(): # to read data from CSV file
with open(' user.csv','r') as newFile:
newFileReader = csv._________(newFile) # Line 3
for row in newFileReader:
print (row[0],row[1])
newFile.______________ # Line 4
addCsvFile(“Arjun”,”123@456”)
addCsvFile(“Arunima”,”aru@nima”)
addCsvFile(“Frieda”,”myname@FRD”)
readCsvFile() #Line 5
(a) Name the module he should import in Line 1.
(b) In which mode, Ranjan should open the file to add data into the file
(c) Fill in the blank in Line 3 to read the data from a csv file.
(d) Fill in the blank in Line 4 to close the file.
(e) Write the output he will obtain while executing Line 5.
34 (i)Evaluate the following expressions: 4
a) 6 * 3 + 4**2 // 5 – 8
6