CS Sample Paper Class 12 2021 with Solution

Share with others

CS Sample Paper Class 12 2021

CS Sample Paper Class 12 2021
CS Sample Paper Class 12 2021
                                               
 COMPUTER SCIENCE TERM 1 SYLLABUS:

Unit I: Computational Thinking and Programming – 2

Revision of Python topics covered in Class XI.

Functions: types of function (built-in functions, functions defined in module, user defined
functions), creating user defined function, arguments and parameters, default parameters,
positional parameters, function returning value(s), flow of execution, scope of a variable (global
scope, local scope)

Introduction to files, types of files (Text file, Binary file, CSV file), relative and absolute paths
Text file: opening a text file, text file open modes (r, r+, w, w+, a, a+), closing a text file, opening a
file using with clause, writing/appending data to a text file using write() and writelines(), reading
from a text file using read(), readline() and readlines(), seek and tell methods, manipulation of data
in a text file

Binary file: basic operations on a binary file: open using file open modes (rb, rb+, wb, wb+, ab, ab+),
close a binary file, import pickle module, dump() and load() method, read, write/create, search,
append and update operations in a binary file

CSV file: import csv module, open / close csv file, write into a csv file using csv.writerow() and read
from a csv file using csv.reader( )

CS Sample Paper Class 12 2021

CS Sample Paper Class 12 2021
CS Sample Paper Class 12 2021

Sample Question Paper

Class: XII Session: 2021-22
Computer Science (Code 083)
(Theory: Term-1)

Maximum Marks: 35 Time Allowed: 90 Minutes

General Instructions:

  1. The question paper is divided into 3 Sections – A, B and C.
  2. Section A, consist of 25 Questions (1-25). Attempt any 20 questions.
  3. Section B, consist of 24 Questions (26-49). Attempt any 20 questions.
  4. Section C, consist of 6 case study based Questions (50-55). Attempt any 5 questions.
  5. All questions carry equal marks.

Section-A

This section consists of 25 Questions (1 to 25). Attempt any 20 questions from this section. Choose the best possible option.

Q1. Find the invalid identifier from the following :

a. Mybook
b. _pass
c. 1Age
d. Num1

Q2. Write the output of the following:

A = list(tuple(“Python”))
print(A)

a. (‘P’, ‘y’, ‘t’, ‘h’, ‘o’, ‘n’)
b. [‘P’, ‘y’, ‘t’, ‘h’, ‘o’, ‘n’]
c. none of the above
d. Error

Ans. b. [‘P’, ‘y’, ‘t’, ‘h’, ‘o’, ‘n’] [/showhide]

Q3. Write the output of the following code.

a=(23, 34, 65, 20, 5)
print(a[0]+a.index(5))

a. 28
b. 29
c. 27
d. 26

Ans. c. 27 [/showhide]

Q4. Which statement will return one line from a file (file object is ‘f’)?

a. f.readline( )
b. f.readlines( )
c. f.read( )
d. f.line( )

CS Sample Paper Class 12 2021

Q6. Which of the following options can be used to read the first line of a text file [CBSE SQP-2021]
data.txt?

a. f = open(‘data.txt’); f.read()
b. f = open(‘data.txt’,’r’); f.read(n)
c. myfile = open(‘data.txt’); f.readline()
d. f = open(‘data.txt’); f.readlines()

Q7. Which of the following error is returned when we try to open a file in write mode which does not exist?

a. FileNotFoundError
b. FileFoundError
c. FileNotExistError
d. None of the above

Q8. ________________________ are the fundamental building block of a python program

a. Identifier
b. Punctuator
c. Constant
d. Token

Q9. How many times will the following code be executed?

a=3
while a>0:
     print(a)

a. 5 times
b. 4 times
c. Infinite times
d. 6 times

Q10. Consider a tuple tup1 = (10, 15, 25, and 30). Identify the statement that will result in an error.

a. print(tup1[2])
b. tup1[2] = 20
c. print(min(tup1))
d. print(len(tup1))

CS Sample Paper Class 12 2021

Q11. The syntax of seek() is: file_object.seek(offset [, reference_point])

What is reference_point indicate?

a. reference_point indicates the starting position of the file object
b. reference_point indicates the ending position of the file object
c. reference_point indicates the current position of the file object
d. None of the above.

Q12. Ashish wants to write data in a binary file. He is confused about file access mode. Help him to identify the correct file mode.

a. rb
b. w
c. w+
d. wb

Q13. The pickle module in Python is used for __________________

a. Serializing any Python object structure
b. De-serializing Python object structure

c. Both a and b
d. None of these

Q14. _____________________ function returns an integer that specifies the current position of the file object.

a. seek( )
b. tell( )
c. pos( )
d. cur( )

Q15. Which keyword is used to begin the definition of a function?

a. Define
b. DEF
c. def
d. Def

CS Sample Paper Class 12 2021

Q16. Write the output of the following:

import random
print(random.choice("csip"))

a. csip
b. s
c. i
d. Either c, s, i or p

Q17. Functions which are already defined in python is called a ___________

a. user defined function
b. library functions
c. built in functions
d. Both b and c

Q18. CSV stands for ______________________

a. Common Separated Value
b. Comma Separated Value
c. Common Sign Value
d. Common Syntax Value

Q19. Which statement will open file “data.txt” in append mode?

a. f = open(“data.txt” , “a”)
b. f = Open(“data.txt” , “ab”)
c. f = new(“data.txt” , “a”)
d. open(“data.txt” , “a”)

Q20. Anshuman wants to work with csv file. He forgot the module to be imported for csv file. As a friend of Anshuman help him to find the module.

a. import CSV
b. import csv
c. import csv_file
d. import csvfile

CS Sample Paper Class 12 2021

Q21. ________________ function is used to write data in binary file.

a. writer( )
b. output( )
c. dump( )
d. send( )

Q22. Which statement is correct for dictionary?

a. A dictionary is an ordered set of key : value pair
b. Keys within a dictionary must be unique
c. Values in the dictionary must be unique
d. Values in the dictionary can not be changed

Q23. Which of the following is invalid operator?

a. +
b. >
c. #
d. and

Q24. Parth wants to open a text file named “data.txt” which is stored in E-drive. As a friend of Parth, help him to find the correct code to open file.

a. rdf = open(“e:\\data.txt”, “r”)
b. rdf = open(“e:\data.txt”, “r”)
c. rdf = open(read = “e:\data.txt”)
d. rdf = open(read = “e:\\data.txt”)

Q25. Amit wants to store a single element in a tuple ‘T’. Help him to find the correct statement given below.

a. T = 7
b. T = (7)
c. T = (7,)
d. T = [7]

CS Sample Paper Class 12 2021

CS Sample Paper Class 12 2021
CS Sample Paper Class 12 2021

Section-B

This section consists of 24 Questions (26 to 49). Attempt any 20 questions.

Q26. Write the output of the following:

a=(23,34,65,20,5)
s=0
for i in a:
    if i%2==0:
         s=s+a[i]
print(s)

a. 54
b. 93
c. 94
d. Error

Q27. Arrange the following task of file handling in correct sequence .

  1. import module
  2. read file
  3. open file
  4. perform operation on file

a. 1, 2, 3, 4
b. 4, 2, 3, 1
c. 1, 3, 2, 4
d. 3, 2, 1, 4

Q28. Write the output of the following code :

L = [5, 4, 78, 6, 12, 32, 45]
L.pop(6)
print(L) 

a. [5, 4, 78, 12, 32, 45]
b. [5, 4, 78, 6, 12, 32]
c. [4, 78, 6, 12, 32, 45]
d. [5, 4, 78, 6, 12, 32, 45]

Q29. Identify the correct output of the following code.

str = 'csip'
s=0
for i in range(len(str)):
  s = s + i
print(s)

a. 0123
b. 5
c. 6
d. 4

Q30. Identify the output of the following Python statements.

d = {9: 'd', 0: 'e', 4: 'f'}
for x in d.values():
    print(x*2, end=",")

a. 18, 0, 8
b. Error
c. dd, ee, ff
d. 9d, 0e, 4f

CS Sample Paper Class 12 2021

Q31. Identify the output of the following Python statements. [CBSE SQP-2021]

lst1 = [10, 15, 20, 25, 30]
lst1.insert( 3, 4)
lst1.insert( 2, 3)
print (lst1[-5])

a. 2
b. 3
c. 4
d. 20

Q32. Aman wants to write a tuple ‘T’ in a binary file “data.dat”. He opened the binary file in read mode with file handle object ‘fn’. Help him to identify the correct code to write tuple in binary file “data.dat”

a. dump(data, T1)
b. dump(T1, data)
c. write(T1, data)
d. load(data, T1)

Q33. Which of the following options can be used to read the 4th line of a text file?

(a) fn=f.readlines()
print(fn[1])
(b) fn=f.readline()
print(fn[1])
(c) fn=f.read()
print(fn[1])
(d) fn=f.readlines()
print(fn[2])

Q34. ___________________ method is used to read the entire file in the form of string.

a. reader( )
b. read( )
c. readlines( )
d. read(n)

Q35. Identify the output of the following code.

def fun():
    a=20
    print(a%4**2, end="&")
a=10
fun()
print(a)

a. 4&10
b. 20&10
c. 0&10
d. Error

CS Sample Paper Class 12 2021

Q36. Which of the following operator can not be used with string :

a. +
b. *
c. **
d. >

Q37. Write the output of the following code:

v = 5
def d(N):
    global v
    v = 25
    if N%9==0:
       v = v * N 
    else:
       v = v ** N 
print(v, end="#")
d(2)
print(v)

a. 5#5
b. 5#25
c. 5#625
d. 5#15

Q38. What will be the output of the following code? [C.B.S.E. SQP 2021]

import random
List=["Delhi","Mumbai","Chennai","Kolkata"]
for y in range(4):
     x = random.randint(1,3)
     print(List[x],end="#")

a. Delhi#Mumbai#Chennai#Kolkata#
b. Mumbai#Chennai#Kolkata#Mumbai#
c. Mumbai# Mumbai #Mumbai # Delhi#
d. Mumbai# Mumbai #Chennai # Mumbai

Q39. Write the output of the following:

print("A")
def prnt():
      print("B")
print("C")
prnt()
a. 

A
B
C
b. 

B
C
A
c.  

A
B
d.  

A
C
B

Q40.  Which module to be imported to make the following line functional?

sys.stdout.write("ABC")

a. system
b. sys
c. stdout
d. stdin

CS Sample Paper Class 12 2021

Q41. Find the output of the following code.

txt = "csip@LEARN"
ntext = "?"
for x in range(len(txt)):
    if txt[x].islower():
        ntext = ntext + txt[x].swapcase()
    elif txt[x].isupper():
        ntext = ntext + txt[x].lower()
    else:
        ntext = ntext + "#"
print(ntext)

a. ?CSIP#learn
b. CSIP#learn
c. ?C?S?I?P#l?e?a?r?n
d. ?CSIP#learn?

Q42. Suppose content of ‘story.txt’ is

Welcome to blog
csiplearninghub.com
One day it will be a
popular blog

Write the output of the following code :

f = open("story.txt","r")
fn = f.read(12)
fn = f.read()
print(fn.count("b"))

a. 1
b. 2
c. 3
d. 4

Q43. Suppose content of ‘story.txt’ is

All the best for your exams

Write the output of the following code :

f = open("story.txt","r")
fn = f.read().split()
print(len(fn))

a. 4
b. 5
c. 6
d. 7

Q44. Write the output of the following code:

def count(x=10, y=25):
     s = x//2 + y
     return s
print(count(20)+count())

a. 35
b. 30
c. 65
d. Error

Q45. Aman is trying to count the number of lines in a file “data.txt”. He wrote the following incomplete code. Help him to complete the code.

f=open("story.txt","r")
nl=f._________________
print("Number of lines are ",len(nl))

a. read( )
b. readline( )
c. readlines( )
d. reader( )

CS Sample Paper Class 12 2021

Q46. Suppose content of ‘data.txt’ is

All the best for your exams

Write the output of the following code :

f=open("data.txt","r")
f.seek(19)
d = f.read()
print(d)

a. our exams
b. ur exams
c. your exams
d. r exams

Q47. ____________ path contains the complete path to the file.

a. absolute path
b. mixed path
c. relative path
d. None of the above

Q48. Akshita wants to store some tabular data in file. Which of the following types of file will be suitable for her?

a. Binary File
b. CSV File
c. Text File
d. None of the above

Q49. Write the output of the following code:

t1 = (3, 2, 3, 8)
t2 = (5, 6, 7)
print(t1>t2)

a. True
b. False
c. Error
d. None of the above

CS Sample Paper Class 12 2021

CS Sample Paper Class 12 2021
CS Sample Paper Class 12 2021

Section-C
Case Study based Questions

This section consists of 6 Questions (50 -55) Attempt any 5 questions.

Ankush is trying to write a function countmemy( ) in Python that counts the number of “Me” or “My” (in smaller case also) words present in a text file “Story.txt”. He has written incomplete code. Help him to complete the code Consider the following text in “Story.txt” file:

My first book was Me and My Family. It gave me chance to be Known to the world.

_________________ countmemy(): #Statement1
  f=open("____________","r") #Statement2
  d = _____________.read() #Statement6
  m = d._________________ #Statement5
  c=0
  for i in _______________: #Statement3
    if i _____________ ["Me","me","My","my"]: #Statement4
      c = c+1
  print("Number is ", c)
countmemy()

Q50. Choose the correct code for statement1

a. define
b. Def
c. def fun
d. def

Q51. Choose the correct code for statement2

a. Story.txt
b. “Story.txt
c. Story
d. Story.txt file

Q52. Choose the correct code for statement3

a. f
b. d
c. m
d. c

Q53. Choose the correct code for statement4

a. in
b. not in
c. and
d. ==

Q54. Choose the correct code for statement5

a. split()
b. break()
c. islower()
d. exit()

Q55. Choose the correct code for statement6

a. fileobject
b. f
c. Any of the above
d. fn

CS Sample Paper Class 12 2021

Disclaimer : I tried to give you the correct solution of “ CS Sample Paper Class 12 2021 , but if you feel that there is/are mistakes in “ CS Sample Paper Class 12 2021 ” given above, you can directly contact me at csiplearninghub@gmail.com. NCERT Book and Study material available on CBSE official website are used as a reference to create above “ CS Sample Paper Class 12 2021

CS Sample Paper Class 12 2021


Chapter Wise Class 12 Computer Science MCQ Questions

1. 150 MCQ on File Handling

2. 120+ MCQ on Python Function

3. 400+ MCQ on Python Revision tour

4. 100+ MCQ on Flow of Control


Important Links

100 Practice Questions on Python Fundamentals

120+ MySQL Practice Questions

90+ Practice Questions on List

50+ Output based Practice Questions

100 Practice Questions on String

70 Practice Questions on Loops

120 Practice Questions of Computer Network in Python

70 Practice Questions on if-else

40 Practice Questions on Data Structure

Computer Science Syllabus 2021-2022.

Informatics Practices Syllabus 2021-2022

Class 12 Computer Science Chapter wise MCQ

CS Sample Paper Class 12 2021





Share with others

Leave a Reply

%d bloggers like this: