XII - CSC Final Paper 2nd 33% Module
XII - CSC Final Paper 2nd 33% Module
General Instructions:
● This question paper contains 37 questions.
● All questions are compulsory.
● The paper is divided into 5 Sections- A, B, C, D and E.
● Section A consists of 21 questions (1 to 21). Each question carries 1 Mark.
● Section B consists of 7 questions (22 to 28). Each question carries 2 Marks.
● Section C consists of 3 questions (29 to 31). Each question carries 3 Marks.
● Section D consists of 4 questions (32 to 35). Each question carries 4 Marks.
● Section E consists of 2 questions (36 to 37). Each question carries 5 Marks.
● All programming questions are to be answered using Python Language only.
● In case of MCQ, text of the correct answer should also be written.
Section – A
I. ANSWER ALL THE QUESTIONS: (21x1=21)
1. State True or False.
An absolute path always begins with the root folder.
2. Which statement is used to retrieve the current position within the file?
a) fp.seek( ) b) fp.tell( ) c) fp.loc d) fp.pos
3. An interrupt or forced disruption that occurs when a program is run or executed is
termed as ______.
a) compile time error b) exception
c) Runtime error d) Logical error
4. Every record in a CSV file is stored in reader object in the form of a list using which
method?
a) writer( ) b) append( ) c) reader( ) d) list ( )
5. Forced exception are indicated using which of the following keywords?
a) try b) except c) finally d) raise
6. Fill in the blanks
______________ is the Python operator responsible for assigning values to the
variables.
7. Which of the following is not considered a valid identifier in Python?
a) two2 b) _man c) hello_rsp1 d) 2 hundred
8. The readlines( ) method returns
a) string b) A list of integers
c) A list of single characters d) A list of strings
9. What will be the output of the following snippet?
f=None
for i in range (5):
with open(“data.txt”, “w”) as f:
if i > 2:
break
print(f.closed)
a) True b) False c) None d) Error
10. Which module is required to use the built-in function dump( )?
a) math b) flush c) pickle d) unpickle
11. Fill in the blanks
To read all the file contents in the form of a list _____ method is used.
12. What will be the output of the following code – print (“100+200”)?
a) 300 b) 100200 c) 100+200 d) 200
13. Which of the following keywords are not specific to exception handling?
a) try b) except c) finally d) else
14. ______ function is used to force transfer of data from buffer to file.
15. Which of the following modes is used for both writing and reading from a binary
file?
a) wb+ b) w c) wb d) w+
16. To open a file c:\test.txt for reading, we should give the statement.
a) file1=open(“c:\test.txt”,”r”) b) file1=open(“c:\\test.txt”,”r”)
c) file1=open(file= “c:\test.txt”,”r”) d) file1=open(file= “c:\s.test.txt”,”r”)
17. Fill in the blanks.
_________ method of pickle module is used to write an object into binary file.
18. To read the entire contents of the file as a string from a file object fobj, the command
should be
a) fobj.read(2) b) fobj.read( )
c) fobj.readline( ) d) fobj.readlines( )
19. What is the output of the following:
x=123
for i in x :
print(i)
a) 1 2 3 b) 123 c) Error d) Infinite loop
SECTION – B (7x2=14)
22. Differentiate between mutable and immutable objects in Python language with
example.
23. What will be the output of the following statement?
a) print(3-10**2+99/11) b) print(3+3.00, 3**3.0)
24. What is the difference between readline( ) and readlines( ) function?
(OR)
Write a statement in Python to perform the following operations
* To open a text file “BOOK.TXT” in read mode
* To open a text file “BOOK.TXT” in write mode
25. Rewrite the following code in Python after removing all syntax error(s). Underlines
each correction done in the code.
Value=30
for VAL in range (D,Value)
If VAL%4==0:
print(VAL*4)
Elseif VAL%5==0:
print(VAL+3)
else
print(VAL+10)
SECTION – C (3x3=9)
29. Write a method in Python to read lines from a text file “DIARY.TXT” and display
those lines which start with the alphabet ‘P’.
(OR)
Write a method in Python to read lines from a text file “MYNOTES.TXT” and display
those lines which start with the alphabet ‘K’.
30. a) A given text file “data.txt” contains:
Line1\n
\n
Line 3
Line 4
\n
Line 6
What would be the output of the following code?
f1=open(“data.txt”,”r”)
lst=f1.readlines( )
print(lst[0])
print(lst[2])
print(lst[5])
print(lst[1])
print(lst[4])
print(lst[3])
(OR)
b)What will be the output of the following program?
x,y,z=5,0,None
print(“a”)
try:
print(“b”)
a=x/y
print(“c”)
except:
print(“d”)
print(“e”)
print(a)
31. Evaluate the following expressions:
a) 16-8**2//6+8 b) 80%3*7*2//8
c) 5==3 or 9 < 2 and 2==2 or not 4 > 1
SECTION – D (4x4=16)
32. Differentiate between a text file, a binary file and a CSV file.
(OR)
Write a program to add (append) Employee records such as employee number,
employee name, salary onto a myfile.csv file.
33. Write a Python program to read specific columns from a “department.csv” file and
print the content of the columns, department id and department name.
34. A binary file “emp.dat” has structure [EmpNo, EmpName, Salary].
Write a user-defined function employee( ) to display all the records one by one. Also
write a function. EmpSal( ) to display the records of all those employees who are
getting salaries from 25000 to 30000.
35. Write a method / function DISPLAYWORDS( ) in Python to read lines from a text file
POEM.TXT and display those words which are less than 4 characters.
SECTION – E ( 2x5=10)
36. A binary file “Book.dat” has structure [BookNo, Book_Name, Author, Price]
Write a user-defined function CreateFile( ) to input data for a record and add to
“Book.dat”. Also write a function CountRec(Author) in Python which accepts the
Author name as a parameter and count and return number of books by the given
Author are scored in the binary file “Book.dat”.
37. a) Write a function in Python to count the number of lines in a text file “STORY.TXT”
which are starting with the alphabet “A”. (3)
b) Define a function to replace all spaces from text with – (dash). (2)
*********
ALL THE BEST