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

CS QP - Class Xi Annual Exam April 30TH

Uploaded by

shrespoor
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)
30 views5 pages

CS QP - Class Xi Annual Exam April 30TH

Uploaded by

shrespoor
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

ANNUAL EXAMINATION - 2023-24

COMPUTER SCIENCE (083)


CLASS : XI DATE : 30-04-2024
MAX MARKS:70 TIME:3 HRS
S.NO SECTION – A MARKS
1 Observe the given python code carefully. 1
a=20
def convert(a):
b=20
a=a+b
convert(10)
print(a)
select the correct output from the given options.
a) 10 b)20 c) 30 d) Error
2 Consider the following python statement: 1
f=open("content.txt")
which of the following is an invalid statement in Python?
a) F.seek(0,1) b) f.seek(1,0)
c) f.seek(0,-1) d) f.seek(0,2)
3 Stack overflow condition is raised in 1
operation whereas Stack underflow condition is raised in
operation.
a) Push,Pop b) Pop,Push
c) Push,Push d) Pop,Pop
4 State True or False. 1
import statement can be written anywhere in the program,
before using a function from that module.
5 Functions that do not return any value are known as: 1
a) Fruitful functions b) void functions
c) library functions d) user defined functions
6 For a function header as follows: 1
def calc(x,y=20):
Which of the following function calls will give an error?
(a) calc(15,25) (b) calc(x=15,y=25)
(c) calc(y=25) (d) calc(x=25)
7 Name the file attribute to check whether the file is 1
closed or not.
8 Which of the following method is used to read a specified 1
number (n) of bytes of data from a text file but maximum
up to the newline character(\n)?
a) read(n) b) readline(n)
c) both a and b d) None of these
9 Which of the following is the correct syntax of file 1
object ‘fobj’ to write a sequence of strings into a file?
(a) fobj.writeline(sequence)
(b) fobj.writelines()
(c) fobj.write(sequence)
(d) fobj.writelines(sequence)
10 Which of the following method is used to serialize the 1
Python object hierarchy?
a) Pickle b)dump c) load d) csv
11 Which of the following function is used to create an 1
object that converts the user data into a csv writable
delimited format?
a) csv.reader() b) csv.writer()
c) csv.writerow() d) csv.writerows()
12 Choose the correct output produced by the following 1
python statement.
print(round(1258.4,-2)
a) 12.0 b) 1300.0 c) 13.0 d) 1258.40
13 Consider a text file ‘DATA,TXT’ and content of the file 1
is as follows:
Hey! Little Fighter,
Soon it will be brighter!
Which of the following option shows the correct output of
the below Python code?
f=open('DATA.TXT')
f.read()
print(f.read())
f.close()
a) Error
b) Hey! Little Fighter,
Soon it will be brighter!
c) No output
d) " "
14 The syntax of seek() is: 1
File object.seek(offset [,reference point])
What is the default value of reference point?
0 b) 1 c) 2 d) 3
15 Which of the following python code represents the peek 1
operation of stack stk in Python?
a) Top=len(stk)-1 b) stk[top]
c) stk.pop() d) None of these
16 Observe the following Python code to traverse a stack stk 1
and display the elements in LIFO methodology.
for K in range( ):
print(stk[K])
a) len(stk),-1,-1 b) len(stk)-1,-1,-1
c) -1,-1,len(stk) d) -1,len(stk)-1,-1
Q. 17 & 18 are Assertion and Reasoning based questions.
Mark the correct choice as
(a) Both (A) and (R) are true and (R) is the correct
explanation of (A)
(b) Both (A) and (R) are true and (R) is not the
correct explanation of (A)
(c) (A) is true but (R) is false
(d) (R) is true but (A) is false
17 Assertion (A): CSV file is a human readable text file 1
where each line has a number of fields, separated by
comma or some other delimiter.
Reasoning (R): writerow() method is used to write a
single row in the csv file.
18 Assertion (A): A stack is a LIFO structure. 1
Reasoning (R): Any new element pushed into the stack
always gets positioned at the index after the last
existing element in the stack.
SECTION – B
19 Atharva is a python programmer working on a program to 2
find and return the maximum value from the list. The code
written below has some syntactical errors. Rewrite the
correct code and underline the corrections made.
def max_num(L)
Max = L[0]
for a in range(L):
If a > Max
Max=a
return max
20 Write any 2 applications of stack. 2
21 (i) Is return statement optional? Comment on the 1+1=2
following return statement.
return
(ii) Write the use of tell() method in Python.
22 Differentiate between ‘w’ and ‘a’ modes in Python. 2
23 Write a function in python POP(Arr), where Arr is a stack 2
implemented by a list of numbers. The function returns
the value deleted from the stack.
24 (i) Write a python statement to write the following 1+1=2
list into a csv file ‘Salary.csv’. Assume the
file object linked to the file ‘Salary.csv’ is
fobj and the writer object is wobj.
Pay=[[‘E01’:75000],[‘E02’,64000],[‘E03’,82000]]
(ii) State True or False.
Relative path always begins with the root
folder.
25 (a) Write the similarity and difference between 2
keyword and positional arguments in Python.
(or)
(b) What are default parameters in Python?
Show a suitable python code.
SECTION – C
26 Write a function EOReplace() in Python, which accepts a 3
list of numbers. Thereafter, it increments all the even
numbers by 1 and decrements all the odd numbers by 1.
Example:
If sample input data of the list is:
L = [10,20,30,35,40,45,55]
Output will be:
L = [11,21,31,34,41,44,54]
27 Write a function in Python, push(vehicle) where vehicle 3
is a dictionary containing details of vehicles –
{car_Name : Maker}.
The function should push the name of car manufactured by
‘TATA’ (including all the possible cases like
Tata,TaTa,TATA etc) into the stack.
28 (i) Write the use of global keyword. 1+2=3
(ii) Write the output of the code given below.
a=30
def call(x):
global a
if a%2==0:
x+=a
else:
x-=a
return x
x=20
print(call(35),end='#')
print(call(40),end='@')
29 Write a function called rem_keys(D,keylist) that accepts 3
two parameters: a dictionary called D and a list called
keylist. Function rem_keys(D,keylist)should remove all
the keys contained in the passed keylist from the
dictionary D and return the dictionary.
30 (a) Write a function UPLOW() in Python that counts 3
and displays the number of uppercase and
lowercase alphabets in a text file ‘PHRASES.TXT’.
(or)
(a) Write a function countwords() in Python that
counts the number of words containing digits
present in a text file “myfile.txt”. Example:
If the “myfile.txt” contents are as follows:
This is my 1st class on Computer Science. There
are 100 years in a Century. Student1 is present
in the front of the line.
The output of the function should be: 3
SECTION – D
31 (A) (i) Write anyone difference between text file 1+3=4
and binary file.
(ii) Consider a binary file ‘items.dat’,
containingrecords stored in the given format:
{‘item_id’ : ___ , ‘item_desc’ : [item_name,amount]}
Write a function Copy_new(), that copies all
records whose amount is greater than 1000 from
items.dat to new_items.dat.
(OR)
(B) Write a Python program with the following user 2+2=4
defined functions.
(i) ADD_DATA() – Accepts Student id and marks
from the user and insert the record into
a binary file ‘student.dat’ in the below
structure [ ID,NAME,MARKS ]
(ii) UPDATE_MARKS(id) – Read the file and
update the student marks whose id is
passed as argument.
32 (A) Write a function PUSH_IN(L), where L is a list of 3+1=4
numbers. From this list, push all numbers which
are multiple of 3 into a stack which is
implemented by using another list in Python.
(B) Observe the following Python code and answer the
question that follow:
File=open(“MyData”,’a’)
What type of file is MyData?
SECTION – E
33 (a) What is the advantage of using with clause 2+3=5
while opening a data file in Python? Also gives
syntax of with clause.
(b) A binary file, EMP.DAT has the following
structure:
[Emp_id,Name,Salary]
Write a user defined function Disp_Detail()
that would read the contents of the file
EMP.DAT and display the details of those
employees whose salary is below 25000.
34 Write a program in Python that defines and calls the 5
following user defined functions:
(i) Add_Book()- Takes the details of the
books and adds them to a csv file
‘BOOK.csv’. Each record consists of a
list with field elements as B_ID,
B_Name and PUBL to store the book id,
name and the publisher respectively.
(ii) Search_Book()- Takes publisher name as
input and counts and displays the
number of books published by them.
35 (a) Write the output of the below Python code. 3+2=5
S="Racecar Car Radar"
def checkpalin(str):
L=str.split()
for W in L:
x=W.upper()
if x==x[::-1]:
for I in x:
print(I,end='*')
else:
for I in W:
print(I,end='#')
print()
checkpalin(S)
(b) Write a Python program to read a text file
‘Poem.txt’ and display all the lines which
contain the python comment character ‘#’.

You might also like