0% found this document useful (0 votes)
23 views6 pages

Class 12 Cs Half Yearly

Uploaded by

suby sbabu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views6 pages

Class 12 Cs Half Yearly

Uploaded by

suby sbabu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

PADMASREE CENTRAL SCHOOL ,ENATHU

HALF YEARLY EXAMINATION- 2024-25


COMPUTER SCIENCE (083)
GRADE : XII MARKS : 70
DATE : /08/24 TIME : 3hr

----------------------------------------------------------------------------------------------------------------------------------

General Instructions:
 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 20 questions (1 to 20). Each question carries 1 Mark.
 Section B, consists of 10 questions (21 to 30). Each question carries 2 Marks.
 Section C, consists of 5 questions (31 to 35). Each question carries 4 Marks.
 Section D, consists of 2 questions (36 to 37). Each question carries 5 Marks.

SECTIONS- A [1 x 20 = 20]

1. Which operator is used in python import all modules from a packages?


a. . operator b. * operator c + operator d , operator
2. Which file must be the part of the folder containing python module files to make it importable
python package?
a. Init.py b. _setup_.py c. _init_.py d. Sys.py
3. Which is the correct command to load just the temp method from a module called usable?
a. Import usable.temp b. Import temp from usable
c. From usable import temp d. Import temp
4. Which of the following random module functions generates a floating point number?
a. random() b. randint() c. uniform() d. All of these
5. An independent triple quoted string given inside a module called _________
a. Documentation string b. Docstring c. Comment d. Stringdoc
6. Which of the following represents mode of both writing and reading in binary format in file?
a. Wb+ b. W c. Wb d. W+
7. Which function is used to write all the characters?
a. Wrte() b. Writelines() c. Writeline()
8. The readlines() method returns __________
a. Str b. A list of lines c. A list of single characters d. A list of integers
9. What will be the output of the following statement:
print(3-2**2**3+99/11)
a. 244 b. 244.0 c. -244.0 d. Error
10. Which of the following will delete key-value pair for key = “Red” from a dictionary D1?
a. delete D1("Red") b. del D1["Red"] c. del.D1["Red"] d. D1.del["Red"]
11. Which of the given argument types can be skipped from a function call?

a. positional arguments b. default arguments


c. keyword arguments d. named arguments
12. A variable declared in a block is local to that block and is known as

a. Local variable b. Global variable


c. Single variable d. Multi variable
13. Select the correct output of the code:

a. PYTHON-IS-Fun b. PYTHON-is-Fun c. Python-is-fun d. PYTHON-Is –Fun


14. Consider the statements given below and then choose the correct output from the given options:
pride="#G20 Presidency"
print(pride[-2:2:-2])
a. ndsr b. ceieP0 c. ceieP d. yndsr
15. Which of the following statement(s) would give an error during execution of the following code?
tup = (20,30,40,50,80,79)
print(tup) #Statement 1
print(tup[3]+50) #Statement 2
print(max(tup)) #Statement 3
tup[4]=80 #Statement 4
a. Statement 1 b. Statement 2 c. Statement 3 d. Statement 4
16. What possible outputs(s) will be obtained when the following code is executed?

a. RED* b. YELLOW* c. WHITE* WHITE* d. YELLOW*


WHITE* WHITE* YELLOW* YELLOW* WHITE*WHITE*
BLACK* BLACK* BLACK* BLACK* BLACK* BLACK* BLACK*
RED* RED* RED* RED* RED* RED* RED* RED* RED*
17. Consider the code given below:
Which of the following statements should be given in the blank for #Missing Statement,
if the output produced is 110?
a. global a b. global b=100 c. global b d. global a=100
18. Which of the following functions changes the position of file pointer and returns its new position?
a. flush() b. tell() c. seek() d. offset()
Q19 and 20 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
19. Assertion(A) : List is an immutable data type
Reasoning(R) : When an attempt is made to update the value of an immutable variable, the old
variable is destroyed and a new variable is created by the same name in memory.
20. Assertion(A) : Python standard library consists of number of modules.
Reasoning(R) : A function in a module is used to simplify the code and avoids repetition.

SECTIONS- B [2 x 10 = 20]
21. The code given below accepts a number as an argument and returns the reverse number. Observe
the following code carefully and rewrite it after removing all syntax and logical errors. Underline
all the corrections made.

22. Differentiate between read() , readline () and readlines().


23. Write the Python statement for each of the following tasks using BUILTIN functions/methods only:
(i) To insert an element 200 at the third position, in the list L1.
(ii) To check whether a string named, message ends with a full stop / period or not.
24. Write a short note on flush() and close() function
25. Differentiate between r+ and w+ mode in file handling.
26. Write a statement to open a text file “REMARKS.TXT” so that existing content can be read from it.
27. What do you understand by local and global scope of variables? How can you access a global
variable inside the function, if function has a variable with same name.
28. What are the different type of files? Explain in short.

30. Explain the different modes to open a file.


29. what is pickling and unpickling? Also explain the methods used in binary files.
SECTIONS- C [4 x 5 = 20]
31. Import random
SCORE=[20,40,10,30,15]
START=random.randint(1,2)
END=random.randint(2,4)
for i in range(START,END+1):
print(SCORE[i],”&”,end=’’)

a. What will be the min and max value that can be assigned to variables START?
i)min=1,max=4 ii)min=1,max=3 iii)min=0,max=4
b. What will be the possible output
i) 10&40&20& ii) 10&30&15&
iii) 40&10&30& iv) 20&40&10&
32. STRING=”CBSEONLINE”
NUMBER= random.randint(0,3)
N=0
While STRING[N]!=’L’:
Print(STRING[N]+STRING[NUMBER]+’#’,end=’’)
NUMBER=NUMBER+1
N=N-1

a. What will be the min and max value that can be assigned to variable NUMBER?
i) min=1,max=4 ii)min=0,max=3 iii)min=0,max=4
b. What will be the possible output for the above code
i) ES#NE#IO# ii) LE#NO#ON#
iii) NS#IE#LO# iv) EC#NB#IS#
33. What will be the output of the Python code?

>>> def testify(a,b):


return a-b
>>> sum=testify(22,55)
>>> sum+30
34. Predict the output of the following code
35. Predict the output of the following code:

SECTIONS- D [5 x 2 = 10]

36. Your teacher has given you a method/function FilterWords() in python which read lines from a text
file NewsLetter.TXT, and display those words, which are lesser than 4 characters. Your teachers
intentionally kept few blanks in between the code and asked you to fill the blanks so that the code will
run to find desired result. Do the needful with the following python code.

def FilterWords():
c=0
file=open('NewsLetter.TXT', '_____________') #Statement-1
line = file.____________ #Statement-2
word = ____________ #Statement-3
for c in word:
if ____________: #Statement-4
print(c)
____________ #Statement-5
FilterWords()

i) Write mode of opening the file in statement-1?


a. a b. ab c. w d. r
ii) Fill in the blank in statement-2 to read the data from the file.
a. File.Read() b. file.read() c. read.lines( ) d. readlines( )
iii) Fill in the blank in statement-3 to read data word by word.
a.Line.Split() b. Line.split() c. line.split() d. split.word()
iv) Fill in the blank in statement-4, which display the word having lesser than 4 characters.
a. len(c) ==4 b. len(c)<4 c. len ( )= =3 d. len ( )==3
v) Fill in the blank in Statement-5 to close the file.
a. file.close() b. File.Close() c. Close() d. end()
37. Krrishnav is looking for his dream job but has some restrictions. He loves Delhi and would take a job there if
he is paid over Rs.40,000 a month. He hates Chennai and demands at least Rs. 1,00,000 to work there. In any
another location he is willing to work for Rs. 60,000 a month. The following code shows his basic strategy
for evaluating a job offer.
Code:
pay = _________
location = _________
if location == "Mumbai":
print ("I’ll take it!") #Statement 1
elif location == "Chennai":
if pay < 100000:
print ("No way") #Statement 2
else:
print("I am willing!") #Statement 3
elif location == "Delhi" and pay > 40000:
print("I am happy to join") #Statement 4
elif pay > 60000:
print("I accept the offer") #Statement 5
else:
print("No thanks, I can find something better")#Statement 6

On the basis of the above code, choose the right statement which will be executed when different inputs for
pay and location are given.
i) Input: location = "Chennai”, pay = 50000
a. Statement 1 b. Statement 2 c. Statement 3 d. Statement 4
ii) Input: location = "Surat" ,pay = 50000
a. Statement 2 b. Statement 4 c. Statement 5 d. Statement 6
iii) Input- location = "Any Other City", pay = 1
a Statement 1 b. Statement 2 c. Statement 4 d. Statement 6
iv) Input location = "Delhi", pay = 500000
a. Statement 6 b. Statement 5 c. Statement 4 d. Statement 3
v) Input- location = "Lucknow", pay = 65000
a. Statement 2 b. Statement 3 c. Statement 4 d. Statement 5

You might also like