Computer Science Term 1 Class 12

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 13

PLACID VIDYA VIHAR SENIOR SECONDARY SCHOOL

TERM 1 MODEL 1
Class : XII
Time Allowed : 90 Minutes Maximum Marks : 35
Subject : (083) Computer Science
General instructions:
The paper is divided into 3 Sections-A, B and C.
Section A, consists of Question 1 to 25 and students need to attempt 20 questions.
Section B, consists of Question number 26 to 49 and students need to attempt 20 questions.
Section C, consists of Question number 50 to 55 and students need to attempt 5 questions.
All questions carry equal marks (0.77 mark per question).

Section – A
Section A consists of 25 questions, attempt any 20 questions

1. Find the valid identifier from the following


1. 2 _Myname
2. My name
3. True
4. Myname_2
2. Which of the following operator can be used with string data type?
1. **
2. %
3. +
4. /
3. Identify the output of the following Python statements.

1. 12.0
2. 13.0
3. 14.0
4. 15.0
4. Identify the output of the following Python statements.

1. 2
2. 3
3. 4
4. 20
5. Which of the following properly expresses the precedence of operators (using parentheses)
in the following expression: 5*3 > 10 and 4+6==11
1. ((5*3) > 10) and ((4+6) == 11)
2. (5*(3 > 10)) and (4 + (6 == 11))
3 .((((5*3) > 10) and 4)+6) == 11
4.((5*3) > (10 and (4+6))) == 11
6. Select which is false for Python function
1. A Python function can return only a single value
2. A function can take an unlimited number of arguments.
3. A Python function can return multiple values
4. Python function doesn‟t return anything unless and until you add a return statement
7. Consider the following program. What is the correct flow of execution of statements:

1. 1,2,3,4,5,6,7,8
2. 1,5,6,7,1,2,3,4,8
3. 5,6,1,2,3,4,7,8
4. 7,8,1,2,3,4,5,6
8. Which is NOT the possible output of following program from given options:

1. Mouse *Keyboard *
2. Mouse *
3. Mouse *Keyboard* Printer*
4.No output
9. What is the output of following program:

1. 5
2. 4
3. 6
4. None of the above
10. What is the output of following program:

1. 2
2.-2
3. 12
4. 5
11.Choose the correct output from the following:

a.1
2
3
b. 1 2 3
c. Error
d. None
12. Which of the arguments can be skipped in the function call?
a. Positional arguments
b. Default arguments
c. Keyword arguments
d. No arguments

13. Which method of pickle module is used to write onto a binary file?
a. dump()
b. load()
c. All of the above
d. None of the above
14.In a program, there is a need of reading whole content of a textfile in a single shot and
store it in the form of list. Suggest the best option among the following
a) read()
b) readline()
c) readlines()
d) None of the above
15. Which of the following statements is true with respect to closing a file
a. It is mandatory to close a text file which is opened
b. Python automatically closes a file
c. Python automatically closes a file if the reference object of the file is allocated to
another
d. None of the above
16. Ajay is studying in an Engineering College in CSE branch. His sister, a class 12 student
of Computer Science comes to him one day asking him the difference between r+ and
w+ modes of a file. What is the correct answer Ajay would give to his sister?
(a) No difference between r+ and w+
(b) In r+ mode, the file is created if it does not exist and erases the content if the file
already exists; w+ raises an error if the file does not exist
(c) In w+ mode, the file is created if it does not exist and erases the content if the file
already exists; r+ raises an error if the file does not exist
(d) Depends on the operating system
17. What is the expected output of the given code?

a) True
b) False
c) None
d) Error

18.

1.J,h,o,n,
2..J,h,n,
3.J,h,
4..None of the above
19.Choose the correct output:

1.0
2.4
3.2
4.3
20.

1.Type error
2.(100,100)
3.(200)
4.(200,)
21. Syntax for opening Student.csv file in write mode is
myfile = open("Student.csv","w",newline='').

What is the importance of newline=''?

a. a.A newline gets added to the file


b. Empty string gets appended to the first line.
c. Empty string gets appended to all lines.
d. EOL translation is suppressed

22. Fill in the blank in the given code:


>>> fo = open("myfile.txt",'w')
>>> lines = ["Hello \n", "Writing strings\n", "third line"]
>>> fo._____________(lines)
>>>myobject.close()

a. write( )
b. writelines( )
c. writeline( )
d. None of the above
23. What will be the output after the execution of the following statements?

a) Delhi
b) ['Delhi', 'Colombo']
c) ['Colombo']
d) Error
24. What will be the output of the following expression:
>>> (50/5**2)
1. 2.0
2. 2
3. 100.0
4. 100
25. What is the minimum and maximum value of c in the following code snippet?
import random
a = random.randint(3,5)
b = random.randint(2,3)
c=a+b
print(c)
a) 3 , 5
b) 5, 8
c) 2, 3
d) 3, 3

Section B
consists of Question number 26 to 49 and students need to attempt 20 questions.

26. What will be the maximum and minimum value of span?


>>>span = int(23 + random.random() * 8)
(1) 30 and 23
(2) 31 and 23
(3) 30 and 24
4) 31 and 24

27.What will be the output when the following code is executed?

A. 0 1
B. 0 1 final
C. 0 final
D. 0 0
28. my home is best in the world. i am a best student. I like computer.
What will be the output of the following code?

A. 1
B. 2
C. 3
D. 4
29. Which of the following is correctly evaluated for this function?
pow(x,y,z)

A. (x**y) / z
B. (x / y) * z
C. (x**y) % z
D. (x / y) / z
30. Write the output of the following:

A. 56
B. 93
C. 94
D.Error
31. Choose the correct output
a. cs@workshop@****
b. CS WORKSHOP 2021
c. cs*workshop*@@@@
d. cs*WORKSHOP*@@@@
32. Choose the correct option:
Statement1: Local Variables are accessible only within a function or block in which it is
declared.
Statement2: Global variables are accessible only within the function in which they are
defined.
a. Statement1 is correct but Statement2 is incorrect
b. Statement2 is correct but Statement1 is incorrect
c. Both Statements are Correct
d. Both Statements are incorrect
33. Choose the correct output

a. kishan
b. 20
c. (kishan, 20)
d. (20,kishan)
34. What will be the output of the following python code:

a) 50@10
b) 150@5
c) 5@50
d) 10@10
35. Choose the correct code to write one record of student(roll_no,name,gender,marks)inbinaryfile
named mybinary.dat:?
A.fileobject=open(“mybinary.dat”,”wb”)
B.fileobject=open(“mybinary.dat”,”wb”)
pickle.dump(listvalues,fileobject)
C.importpickle
listvalues=[1,”Mahi”„F‟,29]
fileobject=open(“mybinary.dat”,”wb”)
pickle.dump(listvalues,fileobject)
D.importpickle
listvalues=[1,”Mahi”„F‟,29]
fileobject=open(“mybinary.dat”,”wb”)
pickle.dump(listvalues,fileobject)
fileobject.close()
36.Suppose content of 'Myfile.txt' is
Honesty is the best policy.
What will be the output of the following code?

A.5
B.25
C.26
D.27
37. Which of the following statement is true?
a. pickling creates an object from a sequence of bytes
b. pickling is used for object serialization
c. pickling is used for object deserialization
d. pickling is used to manage all types of files in Python
38. Evaluate the following expression and identify the correct answer.
16 - (4 + 2) * 5 + 2**3 * 4
a. 54
b. 46
c. 18
d. 32
39. Arun, during Practical Examination of Computer Science, has been assigned an
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.
.In which mode Arun should open the file in Statement-1?
a) r
b) r+
c) rb
d) wb
40. Identify the suitable code to be used at blank space in line marked as Statement-2
a) if(rec[0]==1)
b) for i in range(10)
c) try
d) pass
41. Identify the function (with argument), to be used at blank space in line marked as
Statement-3.
a) load()
b) load(student.dat)
c) load(f)
d) load(fin)
42. What will be the suitable code for blank space in line marked as Statement-4.
a) rec[0]==2
b) rec[1]==2
c) rec[2]==2
d) rec[0]==1
43. 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', 'r')
line = file._____ #Statement-2
word = _____ #Statement-3
for c in word:
if _____: #Statement-4
print(c)
file.close()
FilterWords()
43.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( )
44. 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()
45. 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
46. 46. What will be the output of the following:
print("study"[1])
a.study
b.s
c.t
d.Generate Error
47. What will be the output of the following:
>>> board="CBSE"
>>> print(board[-1::-1])
a.generate error
b.ESBC
c.CBSE
d.None of the above
48. The position of a file-pointer is governed by the___________
A. File mode
B. append mode
C. write mode
D. open mode
49. Following code is written to update a record in file opened with following code.
What will be there in blanks mentioned as Line1 and Line2 in the following code:
import pickle
fin=open(„emp.dat‟, „rb+‟)
try:
while True:
____________=fin.tell( ) #line 1
stu=pickle.load(fin)
if emp[„sal‟] in[2000, 5000 10000]:
emp[„sal‟] +=500
fin.______ (__________) #line 2
pickle.dump(emp, fin)
except EOFError:
fin.close( )

A. Line 1: position= fin.tell( )


Line 2: fin.seek(position)
B. Line 1: position= fin.tell( )
Line 2: fin.tell(position)
C. Line 1: fin.seek( )
Line 2: fin.tell(position)
D. Line 1: fin.seek( )
Line 2: fin.tell( )
SECTION C

Consists of Question number 50 to 55 and students need to attempt 5 questions.


Madhav ,a student of class12th ,is learning CSV File Module in Python. During examination,
he has been assigned an incomplete python code(shown below)to create CSV
File'Stud.csv'(content Shown below).Help him in completing the code which creates the
desired CSV File.
CSVFile

NAME, LOCATION, CITY


Vinay, Jodhpur, JDH
Ajay, Jaipur ,JPR
Smith, Udaipur, UDP

import_______________ #Statement-1
with open(__________________)ascsv1:#Statement-2
abc=csv.__________________#Statement-3
abc.writerow(["NAME","LOCATION","CITY"])
record=[]
whileTrue:
Name=input("EnterName\n")
Location=input("EnterLoc\n")
City=input("EnterCity\n")
data=[______________________]#Statement-4
record.append(_____) #Statement-5
ch=input("insertmorerecord(y/n):")
if ch=='n':
break
abc.______________(record)#Statement-6

50.Identify the suitable code for blank space in Line marked as Statement-1.
A.csvfile
B.CSV
C.csv
D.Csv
51. Identify the missing code for blank space in Line marked as Statement-2?
A."csv1.csv","w"
B."Stud.csv",mode="w"
C."Stud.csv","r”
D."csv1.csv","r”
52.Choose the function name(with argument)that should be used in the blank space of line
marked as Statement-3.
A.reader(csv1)
B.reader(Stud)
C.writer(csv1,delimiter=‟,‟)
D.writer(Stud)
53. Identify the suitable code for blank space in line marked as Statement-4
A.NAME,LOCATION,CITY
B.“Name”,”Location”,”City”
C.name,location,city
D.Name,Location,City

54.Identify the suitable code for blank space in the line marked as Statement-5.
A.data
B.insert
C.record
D.Data

55.Choose the function name that should be used in the blank space of line marked as
Statement-6to create the desired CSVFile?
A.dump()
B.load()
C.writerows()
D.writerow()

You might also like