12th Updated
12th Updated
12th Updated
REVISION TEST - 1
Standard - XII
COMPUTER SCIENCE
Time allowed : 3 hours Maximum Marks : 80
• Please check this question paper contains 35 questions.
• The paper is divided into 4 Sections- A, B, C, D and E.
• Section A, consists of 18 questions (1 to 18). Each question carries 1 Mark.
• Section B, consists of 7 questions (19 to 25). Each question carries 2 Marks.
• Section C, consists of 5 questions (26 to 30). Each question carries 3 Marks.
• Section D, consists of 2 questions (31 to 32). Each question carries 4 Marks.
• Section E, consists of 3 questions (33 to 35). Each question carries 5 Marks.
• All programming questions are to be answered using Python Language only.
Q. No Question Marks
SECTION A
Which one of the following is the function to get list of keys from a dictionary dict in
python?
a. dict.getkeys()
3. 1
b. dict.getvalues()
c. dict.keys()
d. None Of These
Which of the following statement(s) would give an error after executing the following code?
Stud = {“Murugan”:100,”Mithu”:95 } # Statement 1
print (Stud[95]) # Statement 2
Stud [“Murugan”]=99 # Statement 3
print (Stud.pop()) # Statement 4
9.` 1
print (Stud) # Statement 5
a) Statement 2
(b) Statement 3
c) Statement 4
(d) Statements 2 and 4
10. 1
What possible output(s) are expected to be displayed on screen at the time of execution of
the following code ?
CBSE - XII - R1 3 CS
Options :
a) Pencil:Book
b) Pencil:Book
Eraser:Bag
c) Pen:Book
Bag:Book
d) Bag:Eraser
Consider the code given below:
c=1
def add():
# missing statement
c=c+4
print(c)
add()
11. 1
Which of the following statements should be given in the blank for #Missing Statement, if
the output produced is 5 ?
Options:
a. global c
b. global c= 5
c. global 5
d. c= 5 1
14. 1
a) MyCompany/Transactions.Dat
b) MyCompany/Accounts/Transactions.Dat
c) Accounts/Transactions.Dat
d) ../Transactions.Dat
Which of the following methods will give the current position of the file pointer?
15. 1
(a)seek() (b)tell() (c)getloc() (d) None of the above
Q17 and 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 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
SECTION B
Rahul has written a code to input a number and return its reverse. His code is having
errors. Rewrite the correct code and underline the corrections made.
def reverse()
n=int(input(“Enter number :: “)
19. rev=0 2
while(num>0)
r=num%10
rev=rev*10+r
num=num//10
return rev
Write a function countNow(PLACES) which takes a list of names and displays the names
(in uppercase) of the places whose names are longer than 5 characters.
For example, Consider the following List
PLACES= [“Delhi”,”London”,”Paris”,”New York”,”Doha”]
The output should be:
LONDON
20. NEW YORK 2
OR
Write a function, lenWords(STRING), that takes a string as an argument and returns a
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)
PLACES= [“Delhi”,”London”,”Paris”,”New York”,”Doha”]
SECTION C
Write a function count_Dwords () in Python to count the words ending with a digit in a
text file “details.txt”.
Example:
If the file content is as follows:
On seat2 VIP1 will sit and
On seat1 VVIP2 will be sitting
Output will be:
Number of words ending with a digit are 4
OR
Write the definition of a Python function named LongLines ( ) which reads the contents 3
of a text file named ‘lines.txt’ and displays those lines from the file which have at least 10
words in it. For example, if the content of ‘lines.txt’ is as follows:
Once upon a time, there was a woodcutter
He lived in a little house in a beautiful, green wood.
One day, he was merrily choping some wood.
He saw a little girl skipping through the woods, whistling happily.
The girl was followed by a big gray wolf.
28.
Then the function should display output as:
He lived in a little house in a beautiful, green wood.
He saw a little girl skipping through the woods, whistling happily
CBSE - XII - R1 8 CS
A list contains following record of course details for a University:
[Course_name, Fees, Duration]
Write the following user defined functions to perform given operations on the stack named
‘Univ’ :
(i) Push_element() - To push an object containing the
Course_name, Fees and Duration of a course, which has fees
greater than 100000 to the stack.
(ii) Pop_element() - To pop the object from the stack and display it.
29. Also, display “Underflow” when there is no element in the stack. 1*3=3
For example :
If the lists of courses details are :
[‘MCA’, 200000,3]
[‘MBA’, 500000,2]
[‘BA’, 100000, 3]
The stack should contain :
[‘MBA’, 500000,2]
[‘MCA’, 200000,3]
Write the following user defined functions to perform given operations on the stack named
‘stud_details’:
• Push_element() - To Push an object containing name
and age of students who live in hostel “Ganga” to the stack
• 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: 3
[“Barsat”,17,”Ganga”]
[“Ruben”, 16,”Kaveri”]
[“Rupesh”,19,”Yamuna”]
The stack should contain
[“Barsat”,17,”Ganga”]
The output should be:
30.
[“Barsat”,17,”Ganga”]
Stack Empty
SECTION D
Write a function AMCount() in Python, which should read each character of a text file
STORY.TXT, should count and display the occurrence of alphabets A and M (including
small cases a and m too).
For Example:
31 If the file content is as follows: 4
As simplified by official websites.
The EUCount() function should display the output as:
A or a:4
M or m :2
CBSE - XII - R1 9 CS
i. Differentiate w and a in python
32. ii. Write a function display_words() in python to read lines from a text file “story.txt”, and 1+3
display those words, which are less than 4 characters.
SECTION E
Shreyas is a programmer, who has recently been given a task to write a user defined
function named write_bin() to create a binary file called Cust_file.dat containing customer
information – customer number (c_no), name (c_name), quantity (qty), price (price) and
35. amount (amt) of each customer. 5
The function accepts customer number, name, quantity and price. Thereafter, it displays the
message ‘Quantity less than 10 ….. Cannot SAVE’, if quantity entered is less than 10.
Otherwise the function calculates amount as price * quantity and then writes the record in
the form of a list into the binary file.
CBSE - XII - R1 1 CS
0
i) Write the correct statement to open a file 'Cust_file.dat' for writing the data of the
customer.
ii) Which statement should Shreyas fill in Statement 2 to check whether quantity is less than
10.
iii) Which statement should Shreyas fill in Statement 3 to write data to the binary file and in
Statement 4 to stop further processing if the user does not wish to enter more records.
OR
(Option only for part (iii))
iii) What should Shreyas fill in Statement 5 to close the binary file named Cust_file.dat
and in Statement 6 to call a function to write data in binary file?