Class 12 CS Model 1 QST

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

DR RAJU DAVIS INTERNATIONAL SCHOOL,MALA

MODEL EXAMINATION - 1
COMPUTER SCIENCE
CLASS :12 B MARLK:70
TIME:3hrs
Q No. Section-A (21 x 1 = 21 Marks)
1 State True or False
"In Python, data type of a variable depends on its value"
2 What will be the output of the following python expression? print(2**3**2)
a. 64 b. 256 c. 512 d. 32
3 What will be the output of the following python dictionary operation?
data = {'A':2000, 'B':2500, 'C':3000, 'A':4000}
print(data)
a. {'A':2000, 'B':2500, 'C':3000, 'A':4000} b. {'A':2000, 'B':2500, 'C':3000}
c. {'A':4000, 'B':2500, 'C':3000} d. It will generate an error.
4 Select the correct output of the code:
a = "Year 2024 at all the best"
a = a.split('a')
b = a[0] + "-" + a[1] + "-" + a[3]
print (b)
a. Year – 0- at All the best b. Ye-r 2024 -ll the best
c. Year – 024- at All the best d. Year – 0- at all the best
5 Which of the following statement(s) would give an error during execution?
S=["CBSE"] # Statement 1
S+="Delhi" # Statement 2
S[0]= '@' # Statement 3
S=S+"Thank you" # Statement 4
a) Statement 1 b) Statement 2 c) Statement 3 d) Statement 4
6 Choose the ouptut
dic1={‘r’:’red’,’g’:’green’,’b’:’blue’}
for i in dic1:
print (i,end=’’)
a. rgb b. redgreenblue c. red’green’blue d.None
7 Select the correct output of the code:
for i in "QUITE":
print([i.lower()], end= "#")

a. q#u#i#t#e# b. [‘quite#’] c. ['q']#['u']#['i']#['t']#['e']# d. [‘quite’] #


8 Which method is used to move the file pointer to a specified position.
a. tell() b. seek() c. seekg() d. tellg()
9 Identify the output of the following code snippet:
text = "PYTHONPROGRAM"
text=text.replace('PY','#')
print(text)
(A) #THONPROGRAM (B) ##THON#ROGRAM
(C) #THON#ROGRAM (D) #YTHON#ROGRAM
10 Find the output
my_list = [1, 2, 3, 4, 3, 5]
my_list.remove(3)
print(my_list)
a. [1,2,4,5] b. [1,2,3,3,5] c. [1,2,4,3,5] d. none
11 Identify the valid identifier(s) from the given list:
a)1Marks b) $Roll c) Avg Marks d) _sales2008
12 for Name in [‘Ramesh’,’Suraj’,’Priya’]
IF Name[0]='S':
print(Name)
Identify the type of error raised for the above code
a)KeywordError b)SyntaxError c)IndexError c)None
13 Which of the following is a valid arithmetic operator in Python
(i) // (ii) ? (iii) < (iv) and
14 Which of the following expression in python will produce the output 7
(i) 15//2 (ii)15%2 (iii) 15/2 (iv) None
15 State True of False
The execution of following statement will raise an Syntax Error in python
print(print(10))
16 If given A=20, B=15, C=30, What will be the output of following expression:
print((A>B) and (B>C) or (C>A))
a)True b)False c)Error d)None
17 What will be the output of following python code:
for i in range(1,12):
if i%2==0:
continue
print(i)
18 What will be the output of following python code:
x="abAbcAba"
for w in x:
if w=="a":
print("*",end="")
else:
print(w,end="")
19 Which of the following data types is immutable in Python?
A) List B) Dictionary C) Tuple D) Set
Q20 and 21 are ASSERTION AND REASONING based questions. Mark the correct choice as
a. Both A and R are true and R is the correct explanation for A
b. Both A and R are true and R is not the correct explanation for
c. A is True but R is False
d. A is false but R is True
20 Assertion (A):- The number of actual parameters in a function call may not be equal to the
number of formal parameters of the function.
Reasoning (R):- During a function call, it is optional to pass the values to default
parameters.
21 Assertion (A): A tuple can be concatenated to a list, but a list cannot be concatenated to a tuple.
Reason (R): Lists are mutable and tuples are immutable in Python
Section-B ( 7 x 2=14 Marks)
22
23 What is LIFO data structure? Explain the pop() and push() function.
24 Explain any two types of error in python with examples
25 How many times will the following loops will execute and what will be the output
for i in range(1,3,1):
for j in range(i+1):
print(i+1)
26 Writ the output

27 Explain and differentiate r+ and w+ mode in python file handling


28 Explain global variables and local variables with example
Section-C ( 3 x 3 = 9 Marks)
29 Write a Python function that finds and displays all the words longer than 5 characters
from a text file "Words.txt".
30 What do you understand the default argument in function? Which function parameter must
be given default argument if it is used? Give example of function header to illustrate default
argument .
OR
Write a program to reverse a string using stack.
31 Find and write the output of the following python code:
msg = "Technology 2025"
print(msg[3:])
print(msg[:4],msg[4:])
print(msg[::-1])
print(msg[0:4],msg[11:10])
print(msg.strip().lower().replace("Techn", "Method").capitalize())
print(msg.split(‘o’))

Section-D ( 4 x 4 = 16 Marks)
32 (a) What does CSV stand for?
(b) Write a Program in Python that defines and calls the following user defined functions:
(i) InsertRow() – To accept and insert data of an student to a CSV file ‘class.csv’. Each
record consists of a list with field elements as rollno, name and marks to store roll
number, student’s name and marks respectively.
(ii) COUNTD() – To count and return the number of students who scored marks greater
than 75 in the CSV file named ‘class.csv’.
33 Sanjay is working on a binary file, PRODUCTS.DAT, containing records of the following
structure:{‘PID’:Product ID, ‘PNAME’:Product Name , ‘PRICE’:Product Price}
Help him to write the following user defined functions:
(i) appendData(), that reads the values of Product ID, Product Name and Product price
from the user into a dictionary and append it into binary file PRODUCTS.DAT.
(ii) findProduct(product_id) that accepts product_id as argument to read binary file
PRODUCTS.DAT and display the details of that product.
34 Write a program to create a Stack for storing only odd numbers out of all the numbers
entered by the user. Display the content of the Stack along with the largest odd number
in the Stack. (Hint. Keep popping out the elements from stack and maintain the largest
element retrieved so far in a variable. Repeat till Stack is empty)
35 Explain the following
a)tell() and seek() b)positional arguments and keyword arguments

SECTION E (2 X 5 = 10 Marks)
36 Oxford college, in Delhi is starting up the network between its different wings.
There are four Buildings named as SENIOR, JUNIOR, ADMIN and HOSTEL
as shown below:

37 i) What is Pickling or Serialization?


ii) A binary file “salary.DAT” has structure [employee id, employeename, salary]. Write a
function countrec() in Python that would read contents of the file “salary.DAT” and display the
details of those employee whose salary is above 20000.

You might also like