0% found this document useful (0 votes)
165 views9 pages

GRADE 12 PREBOARD-1 (Term-1) Computer Science

The document is an examination paper for Grade XII Computer Science, consisting of multiple sections with varying numbers of questions. It includes multiple-choice questions, short answer questions, and case study-based questions, covering topics such as file handling, data structures, and Python programming concepts. The exam is structured to assess students' understanding and application of computer science principles.
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)
165 views9 pages

GRADE 12 PREBOARD-1 (Term-1) Computer Science

The document is an examination paper for Grade XII Computer Science, consisting of multiple sections with varying numbers of questions. It includes multiple-choice questions, short answer questions, and case study-based questions, covering topics such as file handling, data structures, and Python programming concepts. The exam is structured to assess students' understanding and application of computer science principles.
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

MODERN MIDDLE EAST INTERNATIONAL SCHOOL

Grade XII TERM-1 EXAMINATION 2022-23


COMPUTER SCIENCE (Code-083)
Maximum Marks: 70 Time Allowed: 3 hours

General Instructions:
. The question paper is divided into 5 Sections - A, B, C, D and E.
. Section A consists of 25 Questions (1-25).
. Section B consists of 10 Questions (26-35).
. Section C consists of 7 Questions (36-42).
. Section D consists of 5 Questions (43-47).
. Section E consists of 6 case study based Questions (48-53).
. Attempt all questions.

SECTION-A
This section consists of 25 Questions (1 to 25). Each question carries 1 mark.
Choose the best possible option.

1. Find a valid identifier from the following.


a) break b) none c) True d) def

2. Ravi opened a file in python using open( ) function, but he forgot to specify the mode. In
which mode the file will be opened?

a) write b) append c) read d) both write and read

3. Assume that the following syntax has been used to open a file “[Link]”. Identify the
correct advantage of this method from the following options.

with open ("[Link]", "a") as file_object:

a) In case the user forgets to close the file explicitly the file will be closed automatically.
b) File handle will always be present in the beginning of the file even in append mode.
c) File will be processed faster
d) None of the above
4. Which of the following statements is correct in the context of binary files?
a) Information is stored in the form of Unicode characters.
b) Every line ends with a new line character.
c) pickle module is used for reading and writing
d) Both a and b

Page 1 of 9
5. Consider a tuple, t1=(11,33,55,88). How can you find out the index of the third element of
this tuple?
a)[Link](55) b)[Link](t1[2]) c) t1[2].index() d)Both a and b

6. What is the length of the following string?

st1= "Py thon code"


a)12 b)10 c) 11 d)9

7. Which of the following option is correct about a text file?

a) if we try to write in a text file and that does not exist, an error occurs
b) if we try to write a text file and that does not exist, the file gets created.
c) if we try to read on a text file that does not exist, the file gets created.
d) None of the above
8. Which of the given argument types can be skipped from a function call?
a) positional arguments b) keyword arguments
c) named arguments d) default arguments

9. What is the significance of the seek() method?


a) tells the path of the file.
b) tells the current position of the file pointer within the file.
c) change the position of the file pointer to a given specific position.
d) change the path of the file.

10. Which of the following is NOT true about a dictionary in Python?


a) Keys of a dictionary must be mutable data types
b) Dictionaries are mutable data type
c) len() method can be used to find the length of a dictionary
d) Dictionary stores data as key-value pairs

11. Which of the following is an incorrect logical operator in Python?


a) or b) and c) in d) not

12. Which of the following function headers is/are incorrect?

(i) def f(a = 1, b):


(ii) def f(a = 1, b, c = 2):
(iii) def f(a = 1, b = 1, c = 2):
(iv) def f(a = 1, b = 1, c = 2, d):
a) (i) only b) (i),(ii) and (iv) c) (iii) only d) (ii) and (iii)

13. Which type of errors occurs when rules of programming language are misused?
a) Run time error b) Syntax error
c) Logical error d) Compile time error

14. What will be the output of the following code


city = [„delhi‟,‟agra‟,‟delhi‟,‟pune‟]
[Link](„delhi‟)
a)1 b) 0 c) 2 d) 4

Page 2 of 9
[Link] of the following is not a valid mode to open CSV file?

a) a b) w c) ab d) r

16. How many times the following while-loop will run?


a=5
while a>0:
print(a)
print(“Bye”)

a) 5 times b) Once c) Infinite d) None of these

[Link] of the following is a correct statement about Python functions?

a) We can create function with no argument and no return value.


b) We can create function with no argument and with return value(s)
c) We can create function with argument(s) and no return value.
d) All of the above

18. Which of the following sequences would be generated in the given line of code?
range(5,0,-2)

a) 5 4 3 2 1 0 -1 b) 5 4 3 2 1 0 c) 5 3 1 d) 5 3 1 0

[Link] open a file “c:\[Link]” for reading, we use _______ command.

a) infile = open(“c:\[Link]”, “r”)


b) infile = open(“c:\\[Link]”, “r”)
c) infile = open(file = “c:\[Link]”, “r”)
d) infile = open(file = “c:\\[Link]”, “r”)

20. What will be the output when the following code is executed?
x=100
def func(x):
x=2
x+=2
func(x)
print(x)

a)2 b)100 c)SyntaxError d)102

21. What should be in Line 3, if you want to start writing CSV file using the writer class?
import csv #Line 1
csvfile=open([Link]','w', newline='') #Line 2
________________________ #Line 3

a) obj=[Link]() b) [Link]()
c) obj=[Link]() d) obj=[Link](csvfile)

[Link] method returns an integer that specifies the current position of the file object?

a) seek() b) load() c) position() d) tell()

Page 3 of 9
23. What will be the output of the following code:
t=(4,5,6,7,8,9,3,2,1)
print(t[5:-1])

a) (8,9,3,2,1) b) (9,3,2) c) (4,5,6,7) d) (2,3,9)

24. Mr Subodh is working with a dictionary in python for his project. He wants to display the
key, value pair but confuse out of these statements, choose the correct statement for him:

a) [Link]() b) [Link]() c) [Link]() d) [Link]()

25. If a = 12, b=5 and c=3, what will be the output of the following code?
d=a+b%c
print(d)

a)14 b) 2 c) 5 d)17

SECTION-B
This section consists of 10 Questions (26 to 35). Each question carries 1 mark.

26. Write the full form of CSV.

27. Write a statement in Python to declare a dictionary whose keys are 1, 2, 3 and values are
Monday, Tuesday and Wednesday respectively.

28. A tuple is declared as


T = (2,4,7,5,6)
What will be the value of sum(T)?

29. If the following code is executed, what will be the output of the following code?
name="ComputerSciencewithPython"
print(name[-1:-7:-1])

[Link] the built-in mathematical function / method that is used to return an absolute value
of a number.

[Link] function is used in Python to add multiple elements to the end of a list?

32. Name the module that has to imported to use the functions remove() and rename() while
dealing with files in Python.

33. Which loop in python is known as a „conditional‟ loop?

34. What value does a void function return in Python?

35. What will be the output of following Python code?

list1=["Python","Java","c","C","C++"]
print(min(list1))

Page 4 of 9
SECTION-C
This section consists of 7 Questions (36 to 42). Each question carries 2 marks.

36. The content of a binary file "[Link]" is shown below where the Header is not a
part of file content (i.e only Row1 to Row5 are present in the file)

Header ItemCode Item Qty Rate


101 Pen 1150 25
102 Sharpener 1500 10
Row 1 to Row 5 103 Pencil 1600 12
104 Eraser 1600 5
105 Marker 800 20

def display(Icode):
f=open("[Link]","rb")
totRate=0
try:
while True:
data=[Link](f)
if data[0] in [101,103,105]:
totRate=totRate + data[3]
except:
[Link]()
print(“Total Rate:”,totRate)

When the above-mentioned function, display() is executed, what will be the output?

[Link] between actual parameter(s) and a formal parameter(s) with a suitable


example for each.

38. Write the output of the following:

f=open("[Link]","r")
print([Link](),end="6")
[Link](5)
print([Link]())

39. Find the output of the following code


def display_List(lc):
for x in range(0,len(lc)):
if x%2==0:
print(lc[x],end='#')

lst2=[43,12,66,89,32]
display_List(lst2)

Page 5 of 9
40. What possible outputs(s) from (i) to (iv) is expected to be displayed on screen at the time
of execution of the program from the following code? Also write the minimum and
maximum values that will be assigned to the variable SEL.

import random
SEL=[Link](0,3)
CITY = ["Dubai", "London", "Paris", "Newyork"]
for A in CITY:
for AA in range (1, SEL):
print (CITY[AA], end =" ")
print()

(i) London (ii) Dubai (iii) Dubai London (iv) London Paris
London Dubai Dubai London London Paris
London Dubai Dubai London London Paris
London Duabi Dubai London London Paris

a) Only Option (i) b) Option (ii) and (iii)


c) Option (iv) only d) Option (i) and (iv)
41. Find out the errors in the following code segment. Rewrite the corrected code and
underline the corrections made:
A=integer(input(“Enter first no:”))
B=integer(input(“Enter second no:”))
IF A>B
print(A,”is largest”)
elseif B>A
print(B,”is largest”)
ELSE
print(“Numbers are equal”)

42. Consider the following directory structure:

Page 6 of 9
Suppose the current working directory is Time table. What will be the relative path of the
file [Link]?

SECTION-D
This section consists of 5 Questions (43 to 47). Each question carries 3 marks.

43. Write a function in Python to read lines from a text file "[Link]". Your function should
find and display the occurrence of the word "the".

For example: If the content of the file is:

India is the fastest-growing economy. India is looking for more investments around the
globe. The whole world is looking at India as a great market. Most of the Indians can
foresee the heights that India is capable of reaching.

The output should be 5.

44. Aditi has used a text editing software to type some text. After saving the article as
[Link], she realised that she has wrongly typed alphabet J in place of alphabet I
everywhere in the [Link] a function definition for JTOI() in Python that would
display the corrected version of entire content of the file [Link] with all the
alphabets "J" to be displayed as an alphabet "I" on screen.

For example:If Aditi has stored the following content in the file [Link]:

WELL, THJS JS A WORD BY JTSELF. YOU COULD STRETCH THJS TO BE A SENTENCE

The function JTOI() should display the following content:

WELL, THIS IS A WORD BY ITSELF. YOU COULD STRETCH THIS TO BE A SENTENCE

45. A binary file "[Link]" has structure (admission_number, Name, Percentage).


Write a function count_rec() in Python that would read contents of the file
"[Link]" and display the details of those students whose percentage is above 75.
Also display number of students scoring above 75%.

46. How a binary file is different from a text file. Write the differeces between “w” mode and
“a” mode in Python file handling.

47. Differentiate between keyword arguments and positional arguments. Write appropriate
python code to show examples of the same.

Page 7 of 9
SECTION-E
Case Study based Questions
This section consists of 6 Questions (48 -53) Attempt all the questions.

Minha Shaikh is a programmer, who has recently been given a task to write a python code to
perform the following CSV file operations with the help of two user defined
functions/modules:
a. CSVOpen() : to create a CSV file called [Link] in append mode containing
information of books – Title, Author and Price.

b. CSVRead() : to display the records from the CSV file called [Link] where the field
title starts with 'R'.

She has succeeded in writing partial code and has missed out certain statements, so she has
left certain queries in comment lines.

import _________ #Statement-1

def CSVOpen():
with open('[Link]', '__________' , newline='') as csvf: #Statement-2
cw=______________ #Statement-3
__________________ #Statement-4
[Link](['Rapunzel','Jack',300])
[Link](['Barbie','Doll',900])
[Link](['Johnny','Jane',280])

def CSVRead():
try:
with open('[Link]','r') as csvf:
cr=__________ #Statement-5
for r in cr:
if ___________: #Statement-6
print(r)
except:
print('File Not Found')

CSVOpen()
CSVRead()

48. Identify the suitable code for blank space in the line marked as Statement-1.

a) csv file b)csv c)CSV d)csv module

49. Choose the appropriate mode in which the file is to be opened in append mode
(Statement-2)

a) w+ b) ab c) r+ d) a

50. Which statement will be used to create a csv writer object in Statement -3.

Page 8 of 9
a) [Link](csvf) b) [Link](csvf)
c) [Link]() d) [Link]()

51. Choose the correct option for Statement-4 to write the names of the column headings in the
CSV file, [Link].

a) [Link]('Title','Author','Price')
b) [Link](['Title','Author','Price'])
c) [Link]('Title','Author','Price')
d) [Link](['Title','Author','Price'])

52. Which statement will be used to read a csv file in Statement-5.


a) [Link](csvf) b) [Link](csvf)
c) [Link]() d) [Link](cs)

53. Fill in the appropriate statement to check the field Title starting with „R‟ for
Statement-6 in the above program.

a) r[0][0]=='R' b) r[1][0]=='R'
c) r[0][1]=='R' d) r[1][1]=='R'

Page 9 of 9

You might also like