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

Victoria public sr sec school

CLASS 12 - COMPUTER SCIENCE


Computer Science
Time Allowed: 1 hour and 30 minutes Maximum Marks: 35

General Instructions:

The question paper is divided into 3 Sections - A, B and C.

Section A consists of 25 Questions (1-25). Attempt any 20 questions.

Section B consists of 24 Questions (26-49). Attempt any 20 questions.


Section C consists of 6 case-study-based Questions (50-55). Attempt any 5 questions.
All questions carry equal marks.

Section A
Attempt any 20 questions
1. What is the value of this expression, 3*3**1? [0.77]

a) 3 b) 9

c) 1 d) 27
2. Suppose a tuple T is declared as T = (10, 12, 43, 39), which of the following is incorrect? [0.77]

a) print(T[1]) b) T[2] = -29

c) print(max(T)) d) print(len(T))
3. Which of the following mode will refer to binary data? [0.77]

a) b b) w

c) + d) r
4. The def keyword is followed by the function name and [0.77]

a) parentheses b) argument

c) parameter d) classes
5. Which of the following functions will not result in an error when no arguments are passed [0.77]
to it?

a) float() b) min()

c) all() d) divmod()
6. It is a way to convey a Python object into a character stream: [0.77]

a) Unpickling b) Pickling

c) dump() method d) load() method


7. ________ method of File Input Stream class closes the file input stream and releases any [0.77]
system resources associated with the stream.

a) Int read(byte[] b) b) Void write()

1/9
c) Int read() d) Void close()
8. A ________ can get input from live interaction through keyboard/GUI or it may take input as [0.77]
command line arguments or from the files.

a) Code b) Program

c) Class d) Method
9. To read the next line of the file from a file object infi, we use [0.77]

a) infi.read() b) infi.readlines()

c) infi.readline() d) infi.read(all)
10. Which of the following expressions is an example of type casting? [0.77]
A. 4.0 + float(6)
B. 5.3 + 6.3
C. 5.0 + 3
D. int(3.1) + 7

a) B, C b) A, D

c) A, D d) A, C
11. The following set of commands is executed in shell, what will be the output? [0.77]
>>>str = "hello"
>>>str[:2]
>>>

a) hello b) lo

c) olleh d) he
12. The readlines( ) method returns [0.77]

a) a list of single characters b) string

c) a list of lines d) a list of integers


13. What is a variable defined inside a function referred to as? [0.77]

a) A local variable b) A global variable

c) An automatic variable d) A static variable


14. What is the area of memory called, which stores the parameters and local variables of a [0.77]
function call?

a) an array b) storage area

c) a stack d) a heap
15. To read the remaining lines of the file from a file object infi, we use [0.77]

a) nfi.read( ) b) infi.readlines( )

c) infi.read(all) d) infi.readline( )
16. Which attribute is used to return access mode with that file was opened? [0.77]

a) file.mode b) file.mode.type

2/9
c) mode.file.name d) mode.file
17. Which of the following is not a valid mode to open a file? [0.77]

a) rw b) r+

c) ab d) wb+
18. Which one of these is floor division operator? [0.77]

a) // b) /

c) % d) none of these
19. Which of the following is an invalid statement? [0.77]

a) a, b, c = 1000, 2000, 3000 b) a = b = c = 1,000,000

c) a b c = 1000 2000 3000 d) abc = 1,000,000


20. Given a function that does not return any value, what value is thrown by default when [0.77]
executed in shell?

a) void b) None

c) bool d) int
21. Suppose there is a list such that: l = [2, 3, 4]. [0.77]
If we want to print this list in reverse order, which of the following methods should be
used?

a) reversed(I) b) list(reversed(I))

c) list(reverse[(I)]) d) reverse(I)
22. If return statement is not used inside the function, the function will return: [0.77]

a) Error! Functions in Python must b) An arbitrary integer


have a return statement.

c) None object d) 0
23. If a file is opened for writing, which of the following statements are true? [0.77]
a. The file must exist on the disk on the specified path.
b. If the file exists at the specified path, the file is successfully opened.
c. The file even if at a different location on disk other than the specified path, will get
opened.
d. Python gives error if the file does not exist at the specified path.
e. Python will create a new empty file at the specified path if the file does not exist at the
specified path.
f. The existing contents of the file get erased as soon as you open the file.

a) b, e, f b) b, c, f

c) a, b, c d) d, e, f
24. In file handling, what does these terms means "r and a"? [0.77]

a) read, append b) read, all

c) None of these d) read, always

3/9
25. Information stored on a storage device with a specific name is called a ________. [0.77]

a) array b) file

c) file pointer d) tuple


Section B
Attempt any 20 questions
26. Which two lines of code are valid strings in Python? [0.77]
A. This is a string
B. 'This is a string'
C. (This is a string)
D. "This is a string"

a) A, C b) B, D

c) A, D d) C, D
27. What is the output of the following program : [0.77]
print Hello World [:: -1]

a) Hello World b) drW olH

c) dlroW olleH d) HloWrd


28. You have the following code segment: [0.77]
String1 = "my"
String2 = "work"
print(String1, String2)
What is the output of this code?

a) mywork b) work

c) my d) my work
29. Which of the following is/are built-in function(s)? [0.77]

a) all of these b) input()

c) type() d) print()
30. What is the output of the functions shown below? [0.77]
float('-infinity')
float('inf')

a) -infinity and inf b) Error and Error

c) -inf and inf d) Error and Junk value


31. What is the default return value for a function that does not return any value explicitly? [0.77]

a) double b) None

c) null d) int
32. Which of the following format of files can be created programmatically through Python to [0.77]
store some data?
A. Zip files

4/9
B. Text files
C. Video files
D. Binary files

a) A and D b) B and D

c) A and B d) D and C
33. Which line of code produces an error? [0.77]

a) '1' + 2 b) "one" + "2"

c) "one" + 'two' d) 1 + 2
34. You have the following code segment: [0.77]
print ("Here we have a line of text \n and \n we can do \n newlines!")
What is the output of this code?

a) Here we have a line of text b) Here we have a line of text


and and
we can do newlines! we can do
newlines!

c) Here we have a line of text and we d) Here we have a line of text


can do newlines! and we can do newlines!
35. What will be the output of the following expression? [0.77]
24//6%3, 24//4//2, 48//3//4

a) (0, 3, 4) b) (1, 3, #error)

c) (1, 12, #error) d) (1, 3, 4)


36. What is the output of the below program? [0.77]
def printMax(a, b):
if a > b:
print(a, 'is maximum')
elif a = b:
print(a, 'is equal to', b)
else:
print(b, 'is maximum')
printMax(3, 4)

a) 3 is maximum b) 4

c) 4 is maximum d) 3
37. Which code segment will NOT reach its print( ) function? [0.77]

a) if not 'yes' == 'no' : b) if 'yes’ != 'yes' :


print ("condition met") print("condition met")

c) If 'yes' == ’yes’ : d) if 'yes' ! = 'no' :


print ("condition met") print("condition met")
38. Following set of commands are executed in shell, what will be the output? [0.77]

5/9
>>> str = "hello"
>>> str[:2]

a) he b) llo

c) ello d) hel
39. To read twelve characters from a file object infi, we use [0.77]

a) infi.read(12) b) infi.readline(12)

c) infi.read(13) d) infi.readlines(12)
40. Which of the following are sequence of character data? [0.77]

a) Lists b) Tuples

c) Strings d) Dictionaries
41. Which of the following statements will print the following? [0.77]
hello-how-are-you
A. print('hello', 'how', 'are', 'you')
B. print('hello', 'how', 'are', 'you' + '-' * 4)
C. print('hello-'+ 'how-are-you')
D. print ('hello' + '-' + 'how' + '-' + 'are' + '-' + 'you')

a) B, C b) A, D

c) A, C d) C, D
42. What data type is the object below? [0.77]
L= [1, 23, 'hello', 1]

a) dictionary b) array

c) tuple d) list
43. What is the output of the function shown below? [0.77]
hex(15)

a) 0xF b) 0xf

c) 0Xf d) f
44. Which of the following function calls can be used to invoke the below function definition? [0.77]
def test(a, b, c, d)
i. test(1, 2, 3, 4)
ii. test(a = 1, 2, 3, 4)
iii. test(a = 1, b = 2, c = 3, 4)
iv. test(a = 1, b = 2, c = 3, d = 4)

a) (iii) and (iv) b) (i) and (iii)

c) (i) and (iv) d) (ii) and (iv)


45. Carefully observe the code and give the answer. [0.77]
def function1(a):
a = a + '1'

6/9
a=a*2
>>>function1("hello")

a) hello2 b) cannot perform mathematical


operation on strings

c) hello2hello2 d) indentation error


46. If a file is opened for reading, which of the following statements are true? [0.77]
a. The file must exist on the disk on the specified path.
b. If the file exists at the specified path, the file is successfully opened.
c. The file even if at a different location on a disk other than the specified path, will get
opened.
d. Python gives an error if the file does not exist on the specified path.
e. Python will create a new empty file at the specified path if the file does not exist on the
specified path.
f. The existing contents of the file get erased as soon as you open the file.

a) d, e, f b) a, e, f

c) b, d, e d) a, b, d
47. What is the output of following code ? [0.77]
def f():
x = (2856 / 156) % 89
print(x++)
x* = 34
f()

a) 19 b) 18

c) 646 d) Error
48. What is a variable defined outside all the functions referred to as? [0.77]

a) A local variable b) An automatic variable

c) A static variable d) A global variable


49. To open a file c:\ss.txt for appending data, we use [0.77]
a. file = open("c:\ \ss.txt", "a")
b. file = open("c:\ \ss.txt", "rw")
c. file = open(r"c: \ss.txt", "a")
d. file = open(file = "c:\ss.txt", "w")
e. file = open(file = "c:\ \ss.txt", "w")
f. file = open("c:\ res.txt")

a) c, d b) b, d

c) a, c d) a, d
Section C
Attempt any 5 questions

7/9
Question No. 50 to 55 are based on the given text. Read the text carefully and answer the [4.62]
questions:
a = [36, 29, 21, 19, 50, 72, 34]
print("Original list:", a)
#iterating over a
for i in ________: #Fill 1
j = a.index(i)
#i is not the first element
while ________ #Fill 2
#not in order
if ________: #Fill 3
#swap
________ #Fill 4
else:
#in order
break
j = ________ #Fill 5
print("Sorted list:", a)

50. Choose the correct variable for Fill 1.

a) a b) 1

c) i d) list
51. Choose the correct validation for Fill 2.

a) j = 0 b) j < 0:

c) j > 0 d) j > 0:
52. Choose the correction condition for Fill 3.

a) a[j]: b) a[j - 1] > a[j]

c) a[j - 1] > a[j]: d) a[j - 1]


53. Choose the correct condition for Fill 4.

a) a[j - 1], a[j] = a[j], a[j - 1] b) a[j - 3], a[j] = a[j], a[j - 2]

c) a[j - 2], a[j] == a[j], a[j - 1] d) a[j - 3], a[j - 2] = a[j], a[j - 2]
54. Choose the correct condition for Fill 5.

a) j + 2 b) j

c) j - 1 d) j + 1
55. What can be output obtained?

a) Original list: [36, 29, 21, 19, 50, 72, 34] b) Original list: [36, 29, 21, 19, 50, 72,
Sorted list: [72, 50, 36, 34, 29, 21, 19] 34]
Sorted list: [34, 36, 50, 72, 19, 21, 29]

8/9
c) Sorted list: [19, 21, 29, 70, 50, 36, 34] d) Original list: [36, 29, 21, 19, 50, 72,
34]
Sorted list: [19, 21, 29, 34, 36, 50, 72]

9/9

You might also like