XII COMP Set B

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

OSDAV Public School, Kaithal

First Unit Test (May,2023)


Class :XII SET-B
Subject :Computer Sc.
Time: 1 hr. M.M. : 30
General Instructions:-
I. All questions are compulsory.
II. This Paper contains 4 sections
• A) Consist 4 question carring 1 mark each
• B) Consist 5 questions carrying 2 Marks each
• C) Consist 4 questions carrying 3 Marks each
• D) Consist 1 questions carrying 4 Marks each
Q.N. Questions Marks
Section A(1X5=5)
1 What is the output of the following? 1
x = "osdavkaithal"
for I in x:
print(I,end=”#”)
2 Write a statement in Python to open a binary file student.dat so that new contents can 1
be added at the end of it.
3 Which one of the following have the highest precedence in the expression? 1
a) Exponential b) Addition c) Multiplication d) Parentheses
4 Which is the correct operator to find remainder when x divided by y 1
a) x/y b) x//y c) x%y d) None of the mentioned
Section B(2X5=10)
5 Write a function countwords () in Python to read the text file "story.TXT" and count 2
the number of words starting from ‘m’ or ‘M” in the file.
6 Explain all file modes in Data File Handling in Python for binary file handling. 2
6 Rewrite the following Python code after removing all syntax error(s). Underline the 2
corrections done.
def main():
r = input('enter any radius: ')
a = pi * math.pow(r,2)
print("Area = " + a)
7 Consider the following function calls with respect to the function definition. Identify 2
which of these will cause an error and why?
def si(p, r=5, t=10):
return p*r*t/100
(i) si(1200, 3)
(ii) si(r=50, 35)
(iii)si(2000, r=7, t=15)
(iv) si(r=10, r=12)
8 Find and write the output of the following Python code: 2
L1 = [500,800,600,200,900]
START = 1
SUM = 0
for C in range(START,4):
SUM = SUM + L1[C]
print(C,":",SUM)
SUM = SUM + L1[0]*10
print(SUM).

Page 1 f 2/ UT-1/XII Computer Science Set-B


Section C(3x4=12)
11 What possible outputs(s) are expected to be displayed on screen at the time of 3
execution of the program from the following code? Also specify the
maximum values that can be assigned to each of the variables Lower and
Upper.
import random
AR=[20,30,40,50,60,70];
Lower =random.randint(1,3)
Upper =random.randint(2,4)
for K in range(Lower, Upper +1):
print (AR[K],end=”#“)
(i) 10#40#70# (ii) 30#40#50# (iii) 50#60#70# (iv)40#50#70#
12 a) Observe the following code and answer the questions that follow: (2) 3
File = open("Mydata", "a")
_____________________ #Blank1
File.close()
(i) What type (Text/Binary) of file is Mydata?
(ii) Fill in Blank 1 with a statement to write "ABC" in the file "Mydata".
b) Name the Python Library modules which need to be imported to invoke the
following functions: (1)
(i) load () (ii) pow ()
13 Write a user-defined function named csvreader() that will read the contents of a CSV 3
FILE and display it on screen.
14 Write an algorithm to solve a postfix expression with help of a suitable example 3
Section D(4x2=8)
15 Write a program to search a roll no in a binary file and modify its name of using tell 4
and seek functions

Page 2 f 2/ UT-1/XII Computer Science Set-B

You might also like