0% found this document useful (0 votes)
32 views

Practice Paper

This document contains instructions and questions for a Computer Science exam for Class XII. It includes 20 multiple choice questions and 3 short answer/code writing questions covering topics like Python functions, strings, dictionaries, files and more. Students are instructed to support all answers with Python code examples.

Uploaded by

Aditya Jain
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)
32 views

Practice Paper

This document contains instructions and questions for a Computer Science exam for Class XII. It includes 20 multiple choice questions and 3 short answer/code writing questions covering topics like Python functions, strings, dictionaries, files and more. Students are instructed to support all answers with Python code examples.

Uploaded by

Aditya Jain
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/ 4

SANMATI SCHOOL

COMPUTER SCIENCE(NEW)
CLASS XII(083)
Max Marks : 40 Time: 1½ Hrs

Instructions: (a) All questions are compulsory. (b) All answers should be
supported with examples of python codes.
1 What will be the correct output :- 1
S= “python is very funny language”
print(S.split(“n”))
(i) ['pytho', ' is very fu', ' ', ' ', 'y la', 'guage']
(ii) ['pytho', ' is very fu', ' ','y la', 'guage']
(iii) ['pytho', ' is very fu', 'y la', 'guage']
(iv) ['pytho', ' is very fun', 'y la', 'guage']
2 Select the correct output of the code: 1
S= “WELCOME TO CLASS XII”
L=S.split()
S_new=”#”.join([L[0],L[1].capitalize(),L[2].lower(),L[3].capitlize()])
print(S_new)
(i) Welcome#To#class#Xii
(ii) Welcome#TO#CLASS#XII
(iii) WELCOME#To#Class#Xii
(iv)WELCOME#To#class#Xii
3 Which is the correct way to remove an item from dictionary i.e. Tuesday 1
WEEKD={‘mon’:Monday’, ‘tue’:’Tuesday’, ‘wed’,’Wednesday’}
a. Del WEEKD(‘Tuesday’) b. Del WEEKD[‘Tue’]
c. del WEEKD[‘tue’] d. del.WEEKD[‘tue’]
4 Which function is used to read a single line from a file ? 1
(a) Readline( ) (b) readline( ) (c) Readlines( ) (d) readfullline( )
5 Consider the statements given below and then choose the correct output from the 1
given options: s1="#G20 Presidency"
s2="in the Vidyalaya"
s1_new=s1[-3:2:-2]
s2_new=s2[-3:2:-3]
print(s1_new+s2_new)
(i) ndsr ayVh (ii) ceieP0yaie (iii) ceieP0aadVet (iv) nir0ayVh
6 Which of the following mode is used for both reading and writing in binary in file 1
a. wr+ b. rb+ c. wb d. w+
7 Consider the code given below: 1
X=50
Y=0
def check(Y):
_________ # missing statement
X=Y+X
check(30)
print(X,Y)
Which of the following statements should be given in the blank for #Missing
Statement,
if the output produced is (80,0)
options :
(a) global Y (b) global X=50 (c) global X (d) global Y=-30
8 Which of the following functions (a) changes the position of file pointer and (b) returns 1
its new position?
(i) flush(), read() (ii) seek () , tell() (iii)tell() ,seek() (iv) read(), write()
Q 9 and 10 are ASSERTION AND REASONING based questions. Mark the correct
choice as
(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
9 Assertion(A): Python Standard Library consists of various modules. 1
Reasoning(R): A function in a module is used to simplify the code and avoids
repetition.
10 Assertion (A): If you don’t provide value to argument of function during function call 1
then the function take its default value defined in the function.
Reason (R): during functions call argument are required
11 Rewrite the following code in Python after removing all syntax error(s). 2
Underline each correction done in the code:
Value=30
Def Display(Value): # Function Define
for VAL in range(0,Value)
if(val%4==0):
print(VAL*4)
elif(VAL%5==0):
Print(VAL+3)
Else:
print(VAL+10)
Display(30) # Function call
12 The code given below accepts a number as an argument and returns the reverse 2
number. Observe the following code carefully and rewrite it after removing all syntax
and logical errors. Underline all the corrections made.

13 Write a function showstudent(NAMES) in Python, that takes the dictionary, NAMES 2


as an argument and displays the names of students (in capitalize) whose names are
longer than 4 characters. For example
Consider the following dictionary
NAMES={1:"AKASH",2:"AMIT",3:"AJAY",4:"ROHAN",5:"LAXMICHAND"}

The output should be:


Akash
Rohan
Laxmichand
14 Write a function lenWords(STRING), that takes a string as an argument and returns a 2
tuple containing length of each word of a string.
For example, if the string is "Come let us have some fun",
the tuple will have (4, 3, 2, 4, 4, 3)

15 A list named studentAge stores age of students of a class. Write the Python command 2
to import the required module and (using built-in function) to display the most common
age value from the given list.
16 Predict the output of the following code 2

def Display(str):
m=" "
for i in range(0,len(str)):
if (str[i].isupper()):
m=m+str[i].lower()
elif (str[i].islower()):
m=m+str[i].upper()
else:
m=m+str[i-1]
print(m)
Display('[email protected]')
17 Predict the output of the following:- 3
def change(P=5,Q=10):
P=P/Q
Q=P%Q
return P
A=100
B=10
A=change(A,B)
print( A,B, sep='$')
B=change(B)
print(A,B,sep='$',end='###')

18 Write a function in python showthe() to read the text file “hello.txt” and find out how 3
many lines begin with the word “The” or “THE” .
19 Write a function in python, vowelCount() that count and displays the number of vowels 3
in the text file name “student.txt”
20a How are text files are different from the Binary files? 2
20b A Binary file, CINEMA.DAT has the following structure: {MNO: [MNAME, MTYPE]} 3
Where MNO – Movie Number
MNAME – Movie Name
MTYPE is Movie Type
Write a user defined function, findType(mtype), that accepts mtype as parameter and
displays all the records from the binary file CINEMA.DAT, that have the value of
Movie Type as mtype.
21 Arun, during Practical Examination of Computer Science, has been assigned an 4
incomplete search() function to search in a pickled file student.dat. The File
student.dat is created by his Teacher and the following information is known about the
file.
• File contains details of students in [roll_no,name,marks] format.
• File contains details of 10 students (i.e. from roll_no 1 to 10) and separate list of
each student is written in the binary file using dump().
Arun has been assigned the task to complete the code and print details of roll number
1.
def search():
f = open("student.dat",____) #Statement-1
while True:
rec = pickle.____ #Statement-2
if(____): #Statement-3
print(rec)
________ # statement -4
1. In which mode Arun should open the file in Statement-1?
2. Identify the function(with argument),to be used at blank space in line marked
as Statement-2
3. What will be the suitable code for blank space in line marked as Statement-3
4. Which statement Arun should use at blank space in line marked as Statement4
to close the file

You might also like