Class 12 Computer Science Sample Paper

Sample Paper Class 12

Please refer to the Class 12 Computer Science Sample Paper for the current academic year given below. We have provided the latest CBSE Sample Papers for Term 1 and Term 2 for Computer Science Class 12. All guess sample papers have been prepared based on the latest blueprint and examination pattern for the current year. All sample papers for Computer Science Class 12 Term 1 and 2 have been given with solutions. Students can access the multiple guess papers given below. Practicing more Class 12 Computer Science Sample Papers will help you to get more marks in upcoming exams.

CBSE Sample Papers for Class 12 Computer Science

Term 1 Sample Papers for Class 12 Computer Science
Class 12 Computer Science Sample Paper Term 1 Set A
Class 12 Computer Science Sample Paper Term 1 Set B
Term 2 Sample Papers for Class 12 Computer Science
Class 12 Computer Science Sample Paper Term 2 Set A
Class 12 Computer Science Sample Paper Term 2 Set B

Class 12 Computer Science Sample Paper Term 1 Set A

SECTION – A

1. Which of the following is valid arithmetic operator in Python?
(A) //
(B) ?
(C) <
(D) and

Answer

A

2. Suppose a tuple T is declared as T = (10, 12, 43, 39) which of the following is incorrect?
(A) print(T[1])
(B) T[2] = – 29
(C) print(max(T))
(D) print(len(T))

Answer

B

3. Which of the following is invalid?
(A) _a = 1
(B) __a = 1
(C) __str__ = 1
(D) none of the mentioned

Answer

D

4. Which of the following is/are sorting technique?
(A) Bubble sort
(B) Insertion sort
(C) Both A and B
(D) None of these

Answer

C

5. To open a file “c:\scores.txt” for reading, we use ……………………. .
(A) infile = open(“c:\scores.txt”, “r”)
(B) infile = open(“c:\\scores.txt”, “r”)
(C) infile = open(file = “c:\scores.txt”, “r”)
(D) infile = open(file = “c:\\scores.txt”, “r”)

Answer

B

6. All keywords in Python are in ……………………. .
(A) lower case
(B) UPPER CASE
(C) Capitalized
(D) None of these

Answer

D

7. To read two bytes from a file object infile, we use ……………………….. .
(A) infile.read(2)
(B) infile.read()
(C) infile.readline()
(D) infile.readlines()

Answer

A

8. Which function helps us to randomize the items of a list?
(A) shuffle()
(B) mean()
(C) choice()
(D) max()

Answer

A

9. Which of the following is valid for loop in Python?
(A) for(i=0; i<n; i++)
(B) for i in range(0,5):
(C) for i in range(0,5)
(D) for i in range(5)

Answer

B

10. It determines the mode in which the file has to be opened.
(A) file name
(B) access_mode
(C) dump
(D) pickle

Answer

B

11. Which is the correct form of declaration of dictionary?
(A) Day={1:’monday’,2:’tuesday’,3:’wednesday’}
(B) Day=(1;’monday’,2;’tuesday’,3;’wednesday’)
(C) Day=[1:’monday’,2:’tuesday’,3:’wednesday’]
(D) Day={1’monday’,2’tuesday’,3’wednesday’]

Answer

A

12. Which type of error occurs when rules of programming language are misused?
(A) Syntax error
(B) Semantic error
(C) Run time error
(D) Logical error

Answer

A

13. Which of the following is the use of id() function in python?
(A) id() returns the identity of the object
(B) Every object doesn’t have a unique Id
(C) Both (A) and (B)
(D) None of the mentioned

Answer

A

14. Which of the following is/are compile time errors?
(A) Syntax error
(B) Semantic error
(C) A and B both
(D) None of these

Answer

C

15. Which of the following is an invalid statement?
(A) abc = 1,000,000
(B) a b c = 1000 2000 3000
(C) a,b,c = 1000, 2000, 3000
(D) a_b_c = 1,000,000

Answer

B

16. What keyword would you use to add an alternative condition to an if statement?
(A) else if
(B) elseif
(C) elif
(D) None of these

Answer

C

17. Which of the following refers to mathematical function?
(A) sqrt
(B) Rhombus
(C) add
(D) Rqrt Add

Answer

A

18. Which sorting technique compares two adjoining values and exchanges them?
(A) Bubble sort
(B) Insertion sort
(C) Both A and B
(D) None of these

Answer

A

19. Which of the following is not a complex number?
(A) k = 2 + 3j
(B) k = complex(2, 3)
(C) k = 2 + 3l
(D) k = 2 + 3J

Answer

C

20. In a Python program, a control structure …………………… .
(A) Defines program-specific data structures
(B) Directs the order of execution of the statements in the program
(C) Dictates what happens before the program starts and after it terminates
(D) None of the above

Answer

B

21. Which of the following is an invalid variable?
(A) my_string_1
(B) 1st_string
(C) foo
(D) _my_string

Answer

B

22. What are the two main types of functions?
(i) Custom function
(ii) Built in function
(iii) User defined function
(iv) System function
(A) (i) and (ii)
(B) (ii) and (iii)
(C) (iii) and (iv)
(D) (i) and (iv)

Answer

B

23. Text files store information in ……………………. characters.
(A) ASCII
(B) Unicode
(C) (A) and (B)
(D) None of these

Answer

C

24. Which type of elements are accepted by random. shuffle()?
(A) tuples
(B) dictionaries
(C) lists
(D) strings

Answer

C

25. Which statement will check if a is equal to b?
(A) if a = b:
(B) if a == b:
(C) if a === c:
(D) if a == b

Answer

B

SECTION – B

26. What will be the output of the following code?
print (type(type(int)))
(A) type ‘int’
(B) <class ‘type’>
(C) Error
(D) <class ‘int’>

Answer

B

27. What will be the output of the following Python code?
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

Answer

A

28. What will be the output of the following code?
x = “abcdef”
i = “i”
while i in x:
print(i, end=” “)
(A) a b c d e f
(B) abcdef
(C) i i i i i …
(D) No output

Answer

D

29. What will be the output of the following python code?
def cube (x):
return x * x * x
x = cube (2)
print (x)
(A) 2
(B) 4
(C) 8
(D) 20

Answer

C

30. What will be output of this expression:
‘p’ + ‘q’
(A) pq
(B) rs
(C) pqrs
(D) pq12

Answer

D

31. What will be the output of the following code?
L = [‘a’,’b’,’c’,’d’]
print (“ “.join(L))
(A) Error
(B) a b c d
(C) [‘a’,’b’,’c’,’d’]
(D) None

Answer

B

32. What is the output when the following code is executed ?
print(r”\nhello”)
(A) a new line and hello
(B) \nhello
(C) the letter r and then hello
(D) Error

Answer

B

33. What will be the output of the following code?
x = 12
for i in x:
print(i)
(A) 1 2
(B) 1, 2
(C) Error
(D) None of the above

Answer

C

34. What is the output of 0.1 + 0.2 == 0.3?
(A) True
(B) False
(C) Machine dependent
(D) Error

Answer

B

35. What is the output of “hello”+1+2+3 ?
(A) hello123
(B) hello
(C) Error
(D) hello6

Answer

C

36. Suppose list1 is [3, 4, 5, 20, 5, 25, 1, 3] what is list1 after list1.pop(1)?
(A) [3, 4, 5, 20, 5, 25, 1, 3]
(B) [1, 3, 3, 4, 5, 5, 20, 25]
(C) [3, 5, 20, 5, 25, 1, 3]
(D) [1, 3, 4, 5, 20, 5, 25]

Answer

C

37. In python ~x=-(x+1) then, what does ~~~~~5 evaluate to?
(A) -6
(B) -11
(C) +11
(D) -5

Answer

A

38. Consider the following code and find the answer :
x = 10
print x
x = “Anuj’’
print x
(A) 10
Most recent
(B) 10
Anuj
(C) call back error
invalid command
(D) None of these

Answer

B

39. Identify the most probable incorrect output of random ( ).
(A) 0.02235319431
(B) 1.0234567
(C) 0.0003287169
(D) 0.001234567

Answer

B

40. A text file “MyData.txt” contains following data:
Hello \n
\n
\n
Welcome to AGRA
\n
How \n
Are
You
What would be the output of the following code:
fn = open (“MyData.txt“, “r“)
lst=fn.readlines()
print lst[0],
print lst[3],
print lst[1],
print lst[5]
(A) Hello
Welcome to AGRA 
How
(B) Hello Welcome to AGRA
How
(C) Hello Welcome to AGRA How
(D) Hello
Welcome to AGRA How

Answer

A

41. What will be the output of the following code?
print(math.ceil (random.random( )))
(A) 2.0
(B) will be different every time
(C) 1.0
(D) None of these.

Answer

C

42. Identify the most probable contents that the file “friends.txt” will have after execution of the  following code:

Class 12 Computer Science Sample Paper Term 1 Set A
Answer

A

43. a = input (‘‘ Enter any number ’’)
b = input (‘‘ Enter any number )
c = a + b
print (c)
Predict the output of the above code if input is 56 & 72
(A) 128
(B) 5672
(C) 120
(D) Error will be displayed.

Answer

B

44. Identify the possible set of outputs for the following code.
print (math.pow (random.randint ( 1, 4 ), 3))
If the same statement is repeated 4 times
(1) 18278           (2) 1234
(3) 2231            (4) 182764
(5) 2764864       (6) 12723
(A) 1, 2 and 3
(B) 1, 4 and 5
(C) 3, 5 and 6
(D) 2, 4, 6

Answer

B

45. Which of the following sets is the most probable output if the below given print statement is  repeated three times?
print (12 + random . random (5)
(A) 12.0123, 13.4567, 18.3264
(B) 12.0123, 13.4567, 16.3149
(C) 14.8961, 15.6794, 11.8910
(D) 14.8961, 15.6792, 17.1234

Answer

B

46. Consider the following logical expression (7 > 5) or (50 < 100/0). What will this expression evaluate to?
(A) Gives an error
(B) False
(C) Invalid statement
(D) True

Answer

D

47. Identify the output of the following code:
fn = open (r’E:\myFile.txt’, “r”)
str = ““
while str:
str = fn.readline( )
print str,
fn.close( )
(A) All the lines of the file “myfile.txt” will be printed
(B) The contents of the file will be printed at one go
(C) The complete file will be read in a list str
(D) Contents of the file will be read one line at a time in string strand then printed.

Answer

A

48. Consider the code given below:
def check (a):
a = math.sqrt(a)
return(a)
print(a)
check(25)
The output will be:
(A) Error statement
(B) 25
(C) 5
(D) Nothing will be printed

Answer

D

49. Name the file that is always opened in write mode.
(A) sys.stdin
(B) write.txt
(C) Binary file
(D) sys.stdout

Answer

D

SECTION – C

CASE STUDY BASED QUESTIONS

This section consists of 6 Questions (50 -55) Attempt any 5 questions.
Consider the following code and answer the questions that follow:
Book = { 1 : ‘Thriller’, 2 : ‘Mystery’, 3 : ‘Crime’, 4 : ‘Children Stories’)
Library = { ‘5’ : ‘Madras Diaries’, ‘6’ : ‘Malgudi Days’}

50. Ramesh needs to change the title in the dictionary Book from ‘Crime’ to ‘Crime Thriller’. He has written the following command:
Book[‘Crime’]=’Crime Thriller’
But he is not getting the answer . Help him choose the correct command:
(A) Book[2]=’Crime Thriller’
(B) Book[3]=’Crime Thriller’
(C) Book[2]=(’Crime Thriller’)
(D) Book[3]=(’Crime Thriller’)

Answer

B

51. The command to merge the dictionary Book with Library the command would be:
(A) d=Book+Library
(B) print(Book+Library)
(C) Book.update(Library)
(D) Library.update(Book)

Answer

D

52. What will be the output of the following code:
print(list(Library))
(A) [‘5’,’Madras diaries’,’6’,’Malgudi Days’]
(B) (‘5’,’Madras diaries’,’6’,’Malgudi Days’)
(C) [’Madras diaries’,’Malgudi Days’]
(D) [‘5’,’6’]

Answer

D

53. In order to check whether the key 2 is present in the dictionary Book, Ramesh uses the following command:
2 in Book
He gets the answer ‘True’. Now to check whether the name ‘Madras Diaries’ exists in the dictionary Library, he uses the following command: ‘Madras Diaries’ in Library but he gets the answer as ‘False’. Select the correct reason for this:
(A) We cannot use the in operator with values. It can be used with keys only.
(B) We must use the function Library, values() along with the in operator.
(C) We can use the Library.items() function instead of the in operator.
(D) Both B and C above are correct.

Answer

B

54. With reference to the above declared dictionaries, predict the output of the following code fragments
Code 1 Code 2
Library=Book Library=Book.
copy()
Library. pop (2) Library. pop (2)
print(Library) print(Library)
print (Book) print (Book)

Class 12 Computer Science Sample Paper Term 1 Set A
Class 12 Computer Science Sample Paper Term 1 Set A
Answer

C

55. Every time Ramesh prints the dictionary, he gets different output because:
(A) dictionaries are unordered
(B) dictionaries are ordered
(C) dictionaries keep on changing values associated with keys.
(D) none of these

Answer

A