Xii CS

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

KAMAL PUBLIC SR. SEC.

SCHOOL
Model Test Paper-XII
Subject – Computer Science
MM : 70
General Instructions:

1. This question paper contains five sections, Section A to E.


2. All questions are compulsory.
3. Section A has 15 questions carrying 01 mark each.
4. Section B has 10 questions carrying 02 marks each.
5. Section C has 07 questions carrying 03 marks each.
6. Section D has 02 questions carrying 05 marks each.
7. Section E has 01 question carrying 04 marks
___________________________________________________________________________
Section-A
15*1=15
1. Which of the following is the valid identifier in Python?
a) my_day_2
b) 22nd_day
c) 1_two
d) _@sky
2. How would you write s=ut+1/2at2 in python.

3. Given s1= “Computer Science” . Write the output of print(s1[1:10:2])


4. What is the output of the following code: print fllfl(“5” + “7”)

5. Consider the given expression: not (True and False or False)


Which of the following will be correct output if the given expression is evaluated?
a) True
b) False
c) NONE
d) NULL

6. Which of the following mode in which we can add data in existing file .
a) a+
b) r+
c) w+
d) None

7. What will be the output of the following expression: print(12%3, 23//4//2)


8. Identify the valid relational operator in Python from the following.
a) ? b) < c) ** d) and

9. Which function is used to read a single line from file?


a) readline ( )
b) readlines ()
c) readstatment ()
d) readfullline ( )

10. What is the output of print(“hello”+2)

12. What do you mean by pickling/unpickling


13. Evaluate 22//15%16
14. What do you mean by logical error?
15. A tuple is declared as T = (2,5,6,9,8)
What will be the value of max(T)?

Section-B
10*2=20
1) Shyam has written a code to input a number and check whether it is prime or not. His
code is having errors. Rewrite the correct code andunderline the corrections made.
def_prime():
m=(input("Enter number to check :: ")
for i in range (2, n//2):
if m% I =0:
print(Number is not prime)
else:
print("Number is prime \n”)

2) Given is a Python string declaration:


myboard="@@CBSE Examination 2022@@"
Write the output of: print(myboard[::-3])

3) Write the output of the code given below:


my_dict = {"name": "Radhika", "age": 20}
my_dict['age'] = 27
my_dict['address'] = "Delhi"
print(my_dict.items()

4) Suppose content of 'Myfile.txt' is:

Humpty Dumpty
what you are Up above the world so
high Like a diamond in the sky

What will be the output of the following code?


myfile = open("Myfile.txt")
data = myfile.readlines()
print(len(data))
myfile.close()

5) Rewrite the following code in Python after removing all syntax error(s). Underline each correction done
in the code.

a=10
for i in range(0,p)
If i%2==0:
print (a*4)
else i%5=0:
print (a+3)
else
print(c+10)

6) Predict the output of the Python code given below:


tuple_2 = (10, 20, 30, 40, 50 ,60)
list_20=list(tuple_2)
new_list_20 = []
for a in list_20:
if i not in list_20:
new_list_20.append(a)
print(new_list_20)

7)
Predict the output of the Python code given below:
def div10(n):
if n%10==0:
return n*8
else:
return n+5
def output(m=10):
for i in range(0,m):
print(div10(i),’@’,end=” “)
print(‘\n’)
output(100)
output()
output(25)

8) Find the output of the following Python statements.


x = 2
while x < 9:
print(x, end='') x = x +
1

9) Identify the output of the following Python statements.


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

10) What will be the output of the following code?


y = 5
def myfunc():
global x
y-=2
print(y, end=' ')
print(y, end=' ')
myfunc()
print(y, end=' ')

Section-C 7*3=21
1)
What will be the output of the following code?
def my_func(var1=100, var2=200):
var1+=10
var2 = var2 – 10
return var1+var2
print(my_func(50),my_func())
2) Create a binary file student.dat to hold students’ records like Rollno., Students name, and Address
using the list. Write functions to write data, read them, and print .
3) def ChangeVal(M,N):
for i in range(N):
if M[i]%5 == 0:
M[i]//=5
if M[i]%3 == 0:
M[i]//=3

L = [25,8,75,12]
ChangeVal(L,4)
for i in L:
print(i,end="#")

4) Write a method/function DISPLAYWORDS() in python to read lines from a text file


STORY.TXT, and display those words, which are less than four characters.

5) Write a program to write into file “one.csv” Rollno, Name and Marks separated by comma. It should
have header row and then take in input from the user for all following rows. The format of the file should
be as shown if user enters 2 records.
Roll.No,Name,Marks
20,ronit,67
56,nihir,69
6) Write a user defined function in Python that displays the number of lines starting
with ‘H’ in the filestory.txt.
Eg: if the file contains:

Whose woods these are I think I know.


His house is in the village though;
He will not see me stopping here
To watch his woods fill up with snow.

7) Write a user defined function in python that accept a string as a parameter and display
those wordsfrom the string that starts with capital vowel.
Str= “Exam Of Class Twelve”

Section-D 2*5=10
1) Give any one point of difference between a function text and binary file.
Write a Program in Python that defines and calls the following userdefined functions:
(i) add() – To accept and add data of an employee to a CSVfile ‘empdata.csv’. Each record
consists of a list with field elements as eid, ename and eprice to store employee
id, employee name and employee price respectively.

(ii) search()- To display the records of the furniture whose price is more than 10000

2) What is the advantage of using a csv file for permanent storage?

Write a Program in Python that defines and calls the following userdefined functions:
(i) ADD() – To accept and add data of an employee to a CSV file‘record.csv’. Each record
consists of a list with field elements as empid, name and mobile to store employee id,
employeename and employee salary respectively.
(ii) COUNTR() – To count the number of records present in the CSVfile named ‘record.csv’.

Section-E 2+2

. 1. Write a program to count number of records present in “data.csv” file.

2. What is the output of the following program if the student.csv file contains following data?
Student.csv
Ronit, 200
Akshaj, 400
Program
import csv
d = csv.reader(“student.csv”)
for row in d:
print (row)

You might also like