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

XII - CSC Final Paper 2nd 33% Module

Uploaded by

kkaneeshkarank
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)
38 views

XII - CSC Final Paper 2nd 33% Module

Uploaded by

kkaneeshkarank
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

Class : XII Marks : 70

Date : 15.10.2024 COMPUTER SCIENCE Duration : 3 hours

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

Q. 20 and 21 are ASSERTION·(A) and REASONING (R) 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.
20. Assertion (A) : Every small unit in a Python programming statement in termed as a
token.
Reason (R) : Tokens are not interpreted but are an integral part while designing the
code .
21. Assertion (A) : The file access mode used to add or append the data in the file is ‘a’.
Reason(R) : In the access mode, ‘a’, the text will be append at the end of the existing
file. If the file does not exist, Python will create a new file and write data to it.

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)

26. Convert the following for loop into while loop.


for k in range (10,20,5):
print(k)
27. Write the output of the following:
for x in range(1,6):
for y in range(1,x+1):
print(x,” “,y)
28. Write a single loop to display all the contents of a text file “file1.txt” after removing
leading and trailing whitespaces.
(OR)
Differentiate between the modes r+ and w+ with respect to text files in Python.

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

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy