0% found this document useful (0 votes)
59 views5 pages

12 Computer (2022-23)

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views5 pages

12 Computer (2022-23)

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Dev Public School

Class – 12
Pre-Board Exam – 1
Computer Science
Max. Marks – 70
--------------------------------------------------------------------------------------------------------------------------------------------
SECTION A
( 1 mark × 20 = 20marks)
Q1: Find the invalid identifier from the following:
a. type b. None c. Name d. Pass

Q2: What will be the output of the following Python code?


def add (num1=10, num2=23):
sum = num1 + num2
return sum
print(add(20), add(10,20)
a) 43 30 b) 20 23 c) 10 20 d) 30. 23

Q3: Suppose content of 'Myfile.txt' is


How I wonder what you are
Up above the world so high
Like a diamond in the sky

Q4: What will be the output of the following code?


myfile = open("Myfile.txt")
record = myfile.readline().split()
print(len(record))
myfile.close()
a) 18. b) 3 c) 6. d) 5

Q5: What is the output of following code:


a=30
b=(2)
c=(25,)
print(a*b,c*b)
a) 60 (25, 25) b) 30 (50) c) (60)(25,25). d) 30 50

Q6: Given a Tuple tup1= (10, 20, 30, 40, 50, 60, 70, 80, 90)
print(tup1[-8:-2:2])
a) (20, 30, 40, 50, 60, 70) b) (20,30,40).
c) (20, 40, 60). d) (30,40,50)

Q7: Which of the following options can be used to read the first character of a text file Myfile.txt?
a) myfile = open('Myfile.txt')
myfile.read(1)
b) myfile = open('Myfile.txt','r')
myfile.read(n)
c) myfile = open('Myfile.txt')
myfile.readline()
d) myfile = open('Myfile.txt')
myfile.readlines()
Q8: What is the correct expansion of TSV files?
a) Tab Separable Values b) Tab Separated Values
c) Tab Split Values d) Tab Separation Values
Q9: What will be the output of the following code?
t1=[12,34,(45,67,[56]),78]
t1[2][2][0]=34
print(t1[2][2][0])
a) 56 b) 78 c) 34 d) Error Message

Q9: What will be the output of the following code?


x=3
def myfunc():
x=10
x+=5
print(x, end=' ')
myfunc()
print(x, end=' ')
a) 3 15 b) 15 3 c) 15 5 d) 3 5

Q10: Which of the following statement is true?


a) pickling creates an object from a sequence of bytes
b) pickling is used for object deserialization
c) unpickling is used for object deserialization
d) pickling is used to manage all types of files in Python

Q11: 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

Q12: What is the significance of the seek() method?


a. tells the path of file
b. tells the current position of the file pointer within the file
c. tells the end position within the file
d. change the existence of a file at the desired location

Q13: Which of the following components are part of a function call statement in Python?
a. Function Name
b. Return Statement
c. Parameter List
d. Both a and c

Q14: Which of the following method is used to read a binary file in python?
a. read() b. reader() c. load() d. dump()

Q15: Python was created by ____________.


a) James Gosling b. Steve Jobs c. Guido van Rossum d. Dennis ritche

Q16: What is used to define a block of code (body of loop, function etc.) in Python?
a) Curly braces b. Parenthesis c. Indentation d. Quotation

Q17: To insert 5 to the third position in list1, we use which command?


a) list1.insert(3, 5)
b) list1.insert(2, 5)
c) list1.add(3, 5)
d) list1.append(3, 5)
Q18: What will be the output of the following Python code?
>>>"Welcome to Python".split()
a) [“Welcome”, “to”, “Python”] b) (“Welcome”, “to”, “Python”)
c) {“Welcome”, “to”, “Python”} d) “Welcome”, “to”, “Python”

Q19: Suppose list1 is [3, 4, 5, 20, 5, 25, 1, 3], what is list1.count(5)?


a) 0. b) 4 c) 1 d) 2

Q20: A Python paragraph comment uses the style ________.


a. // comments //. b. / comments / c. ''' comments ''' d. # comments

SECTION B. ( 3 marks × 5= 15 marks)

Q21: Write a user-defined function in python that displays the number of lines starting with ‘H’ in the file
para.txt. Example , if the file contains:
Whose woods these are I think I know
His house is in the village though;
He will not see me stopping here
To watch his woods fill up with snow
Then the line count should be 2

Q22 :Write a method in python to read lines from a text file DIARY.TXT and display those lines which start
with the alphabet ’K’.

Q23: How is method read() different from readline() in python?

Q24: Write a method/function AEDISP() in python to read lines from a text file WRITER.TXT, and display
those lines, which are starting either with A or starting with E.
For example : If the content of the file is
A CLEAN ENVIRONMENT IS NECESSARY FOR OUR GOOD HEALTH.
WE SHOULD TAKE CARE OF OUR ENVIRONMENT.
EDUCATIONAL INSTITUTIONS SHOULD TAKE THE LEAD.
The method should display:
A CLEAN ENVIRONMENT IS NECESSARY FOR OUR GOOD HEALTH.
EDUCATIONAL INSTITUTIONS SHOULD TAKE THE LEAD

Q25: What is the difference between local and global variables? Explain giving example.

SECTION C. (4 marks × 5= 20 marks)

Q26: What is the advantage of using a csv file for permanent storage? Write a Program in Python that defines
and calls the following user defined functions:
a) ADD() – To accept and add data of an employee to a CSV file ‘record.csv’. Each record consists of a
list with field elements as empid, name and mobile to store employee id, employee name and
employee salary respectively.
b) COUNTR() – To count the number of records present in the CSV file named ‘record.csv’.

Q27: Predict the output of the Python code given below:


A) def Diff(N1,N2):
if N1>N2:
return N1-N2
else:
return N2-N1
NUM= [10,23,14,54,32]
for CNT in range (4,0,-1):
A=NUM[CNT]
B=NUM[CNT-1]
print(Diff(A,B),'#', end=' ')

B) tuple1 = (11, 22, 33, 44, 55 ,66)


list1 =list(tuple1)
new_list = []
for i in list1:
if i%2==0:
new_list.append(i)
new_tuple = tuple(new_list)
print(new_tuple)

Q28: Write a function ETCount() in Python, which should read each character of a text file “TESTFILE.TXT”
and then count and display the count of occurrence of alphabets E and T individually (including small
cases e and t too).
Example:
If the file content is as follows:
Today is a pleasant day.
It might rain today.
It is mentioned on weather sites
The ETCount() function should display the output as:
The number of E or e: 6
The number of T or t : 9

Q29: Write a function countmy( )in Python to read the text file “DATA.TXT” and count the number of times
“my” occurs in the file. For example if the file “DATA.TXT” contains:
“This is my website. I have displayed my preferences in the CHOICE section.”
The coutmy() function should display the output as: “my occurs 2 times”.

Q30: Evaluate the following postfix using stack & show the content of the stack after the execution of each: 12,
7,3,-, /,2 ,1 , 5, +, * ,+

Section D. (Attempt any 3) ( 3*5= 15 Marks)

Q31: Convert the following Infix expression to its equivalent Postfix expression, showing the stack contents for
each step of conversion:
a) A+B-D/X. b) (X+Y)/(Z*Y)-R

Q32: Write a program depending upon user’s choice either pushes or pops an element in A Stack?
MakeInIndia Corporation, an Uttarakhand based IT Training company, is planning to set up training
centers in various cities in next 2 years. Their first campus is coming up in Kashipur district. At Kashipur
campus, they are planning to have 3 different blocks for App development, Web designing and Movie
Editing. Each block has number of computers, which are required to be connected in a network for
communication, data and resource sharing. As a network consultant of this company, you have to suggest
the best network related solutions for them for issues/problems raised in question nos. (i) to (v), keeping
in mind the distance between various blocks/locations and other given parameter.
Block and Distance:
App development to Web designing 28 m
App development to Movie editing 55 m
Web designing to Movie editing 32 m
Kashipur Campus to Mussoorie Campus 232 km
Number of computers:
Block and Number of Computers:
App development 75
Web designing 50
Movie editing 80

(i) Suggest the most appropriate block/location to house the SERVER in the Kashipur campus (out of
the 3 blocks) to get the best and effective connectivity. Justify your answer.
(ii) Suggest a device/software to be installed in the Kashipur Campus to take care of data security.
(iii) Suggest the best wired medium and draw the cable layout (Block to Block) to economically connect
various blocks within the Kashipur Campus.
(iv) Suggest the placement of the following devices with appropriate reasons:
a. Switch / Hub b. Repeater
(v) Suggest the protocol that shall be needed to provide Video Conferencing solution between Kashipur
Campus and Mussoorie Campus.

Q34: Aman is a Python programmer. He has written a code and created a binary file record.dat with
employeeid, ename and salary. The file contains 10 records. He now has to update a record based on the
employee id entered by the user and update the salary. The updated record is then to be written in the
file temp.dat. The records which are not to be updated also have to be written to the file temp.dat. If the
employee id is not found, an appropriate message should to be displayed.As a Python expert, help him to
complete the following code based on the requirement given above:
import _______ #Statement 1
def update_data():
rec={}
fin=open("record.dat","rb")
fout=open("_____________") #Statement 2
found= False
eid=int(input("Enter employee id to uptheir. their salary :: "))
while True:
try:
rec=______________ #Statement 3
if rec["Employee id"]==eid:
found=True
rec["Salary"]=int(input("Enter new salary :: "))
pickle.____________ #Statement 4
else:
pickle.dump(rec,fout)
except:
break
if found==True:
print("The salary of employee id ",eid," has been updated.")
else:
print("No employee with such id is not found")
fin.close()
fout.close()
(i) Which module should be imported in the program? (Statement 1)
(ii) Write the correct statement required to open a temporary file named temp.dat for writing the
updated data. (Statement 2)
(iii) Which statement should Aman fill in Statement 3 to read the data from the binary file, record.dat
and in Statement 4 to write the updated data in the file, temp.dat?

You might also like