Class 12 Sample Paper
Class 12 Sample Paper
Section
–A
Q01. State True or False (1)
“Tuple is datatype in Python which contain data in key-value pair.”
Which of the following will be correct output if the given expression is evaluated?
(A) True (B) False
(C) NONE (D) NULL
Q05. Select the correct output of the code: (1)
>>> s='[email protected]'
>>> s=s.split('kv')
>>> op = s[0] + "@kv" + s[2]
>>> print(op)
(A) mail2@kvsangathan (B) mail2@sangathan.
Page1|7
Q07. Fill in the blank: (1)
command is used to change table structure in SQL.
(A) update (B) change
(C) alter (D) modify
Q08. Which of the following commands will remove the entire database from MYSQL? (1)
(A) DELETE DATABASE (B) DROP DATABASE
(C) REMOVE DATABASE (D) ALTER DATABASE
Q09. Which of the following statement(s) would give an error after executing the following (1)
code?D={'rno':32,'name':'Ms Archana','subject':['hindi','english','cs'],'marks':(85,75,89)}
#
S1 print(D)
#
S2
D['subject'][2]='IP' #S3
D['marks'][2]=80 #S4
print(D) #S5
(A) S1 (B) S3
(C) S4 (D) S3 and S4
Q10. Fill in the blank: (1)
is a non-key attribute, whose values are derived from the primary key of some other
table.
(A) Primary Key (B) Candidate Key
(C) Foreign Key (D) Alternate Key
Q11. The correct syntax of seek() is: (1)
(A) seek(offset [, reference_point]) (B) seek(offset, file_object)
(C) seek.file_object(offset) (D) file_object.seek(offset [, reference_point])
Page2|7
Q14. What will the following expression be evaluated to in Python? print ( round (100.0 / 4 + (3 + (1)
2.55) , 1 ) )
(A) 30.0 (B) 30.55
(C) 30.6 (D) 31
Q15. Which function is used to display the total number of records from a table in a database? (1)
(A) total() (B) total(*)
(C) return(*) (D) count(*)
Q16. In order to open a connection with MySQL database from within Python using mysql.connector (1)
package, function is used.
(A) open (B) connect
(C) database() (D) connectdb()
Q17 and 18 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 A
(C) A is True but R is False
(D) A is false but R is True
Q17. str1= “Class” + ”Work” (1)
ASSERTION: Value of str1 will be “ClassWork”.
REASONING: Operator ‘+’ adds the operands, if both are numbers & concatenates the string if
both operands are strings.
Q18. Assertion: CSV (Comma Separated Values) is a file format for data storage which looks (1)
like atext file.
Reason (R): The information is organized with one record on each line and each field is
separated
by semi-colon.
Section–
B
Page3|7
Q19. Vivek has written a code to input a number and check whether it is even or odd number. His (2)
codeis having errors. Rewrite the correct code and underline the corrections made.
Def
checkNumber
(N):status =
N%2 return
#main-code
num=int( input(“ Enter a number to check
:))k=checkNumber(num)
if k = 0:
print(“This is EVEN
number”)else:
print(“This is ODD number”)
Q20. Write two points of difference between Bus topology and star topology. (2)
OR
Write two points of difference between XML and HTML.
OR
(i) Select BRAND_NAME, FLAVOUR from CHIPS where PRICE <> 10;
(ii) Select * from CHIPS where FLAVOUR=”TOMATO” and PRICE > 20;
(iii) Select BRAND_NAME from CHIPS where price > 15 and QUANTITY < 15;
(iv) Select count( distinct (BRAND_NAME)) from CHIPS;
(v) Select price , price *1.5 from CHIPS where FLAVOUR = “PUDINA”;
(vi) Select distinct (BRAND_NAME) from CHIPS order by BRAND_NAME desc;
Q27. Write a function countINDIA() which read a text file ‘myfile.txt’ and print the (3)
frequencyof the words ‘India’ in it (ignoring case of the word).
Example: If the file content is as follows:
output as:
Frequency of India is 3
OR
Page5|7
Write a function countVowel() in Python, which should read each character of a text file
“myfile.txt” and then count and display the count of occurrence of vowels (including small
cases
Q28. (A) Consider the following tables BOOKS and ISSUED in a database named (3)
“LIBRARY”. Write SQL commands for the statements (i) to (iv).
Table: BOOKS
Table: ISSUED
(i) Display book name and author name and price of computer type books.
(ii) To increase the price of all history books by Rs 50.
(iii) Show the details of all books in ascending order of their prices.
(iv) To display book id, book name and quantity issued for all books which have been issued.
(B) Write the command to view all tables in a database.
Q29. Write a function lenFOURword(L), where L is the list of elements (list of words) (3)
passed as argument to the function. The function returns another list named
‘indexList’ that stores the indices of all four lettered word of L.
For example:
(i) pushElement() - To Push an object containing name and mobile number of students
who belong to class xii and section ‘a’ to the stack
(ii) popElement() - To Pop the objects from the stack and display them. Also, display
Page6|7
“Stack Empty” when there are no elements in the stack.
For example:
If the lists of students details are:
[“Rajveer”, “99999999999”,”XI”, “B”]
[“Swatantra”, “8888888888”,”XII”, “A”]
[“Sajal”,”77777777777”,”VIII”,”A”]
[“Yash”, “1010101010”,”XII”,”A”]
OR
Page7|7
Q31. Aryan Infotech Solutions has set up its new center at Kamla Nagar for its office and web based (5)
activities. The company compound has 4 buildings as shown in the diagram below:
Orbit
Building
Sunrise
Jupiter
Building
Building
Oracle
Buildig
Page8|7
Oracle Building 15
Sunrise Building 35
#main-
codea=10
b=5
printMe(a,
b)
printMe(r=4,q=2)
(B) The code given below inserts the following record in the table Student:
Page9|7
Statement 2 – to execute the command that inserts the record in the table Student.
Statement 3 - to add the record permanently in the database
import mysql.connector as mysql
def sqlData():
con1=mysql.connect(host="localhost",user="root", password="toor@123",
database="stud")mycursor = #Statement 1
rno=int(input("Enter Roll Number :: "))
name=input("Enter name :: ")
clas=int(input("Enter class :: "))
marks=int(input("Enter Marks :: "))
querry="insert into student values({},'{}',{},{})".format(rno,name,clas,marks)
#Statement 2
# Statement 3
print("Data Added successfully")
OR
(A) Predict the output of the code given below:
s="C++VsPy"
m=""
for i in range(0, len(s)):
if (s[i] >= 'a' and s[i] <= 'm'):
m = m +s[i].upper()
elif (s[i] >= 'n' and s[i] <= 'z'):
m = m +s[i-1]
elif (s[i].isupper()):
m = m + s[i].lower()
else:
m = m +'&'
print(m)
(B) The code given below reads the following record from the table named student and
displaysonly those records who have marks greater than 90:
P a g e 10 |
7
Note the following to establish connectivity between Python and MySQL:
* Username is root
* Password is toor@123
* The table exists in a “stud” database.
Write the following missing statements to complete the code:
Statement 1 – to form the cursor object
Statement 2 – to execute the query that extracts records of those students whose marks are greater
than 90.
Statement 3- to read the complete result of the query (records whose marks are greater than 90)
into the object named data, from the table student in the database.
import mysql.connector as mysql
def sql_data():
con1=mysql.connect(host="localhost",user="root",password="toor@123",
database="stud")mycursor= #Statement 1
print("Students with marks greater than 90 are : ")
#Statement 2
data= #Statement
3for i in data:
print(i)
print()
Q33. What is the advantage of using a csv file for permanent storage? (5)
Write a Program in Python that defines and calls the following user defined functions:
(i) ADD() – To accept and add data of a teacher to a CSV file ‘teacher.csv’. Each record consists
of a list with field elements as tid, name and mobile to store teacher id, teacher name and
teachermobile number respectively.
(ii) COUNTRECORD() – To count the number of records present in the CSV file
named‘teacher.csv’.
OR
Give any one point of difference between a binary file and a csv file.
Write a Program in Python that defines and calls the following user defined functions:
P a g e 11 |
7
(i) add() – To accept and add data of an employee to a CSV file ‘employee.csv’. Each record
consists of a list with field elements as eid, name and salary to store employee id, employee
nameand employee salary respectively.
(ii) search()- To display the records of the employee whose salary is more than 40000.
Section
–E
Q34. Layna creates a table STOCK to maintain computer stock in vidyalaya. After creation of (1+
thetable, she has entered data of 8 items in the table. 1+
2)
P a g e 12 |
7
updated also have to be written to the file temp.dat. If the student id is not found, an
appropriatemessage should to be displayed.
As a Python expert, help him to complete the following code based on the requirement
givenabove:
import #Statement 1
def
update_data
():rec={}
fin=open("record.dat","rb")
fout=open(" ")
#Statement 2found=False
sid=int(input("Enter student id to update his marks ::
"))while True:
try:
rec =
#Statement 3if rec["studentid"]==sid:
found=True
rec["marks"]=int(input("Enter new marks :: "))
pickle. #Statement 4
else:
pickle.dump(rec,fout)
except:
break
if found==True:
print ("The marks of studentid ", sid ," has been updated.")
else:
print("No student with such id is not
found")fin.close()
fout.close()
(i) Which module should be imported in the program? (Statement 1)
(ii) Write the correct statement required to open a temporary file named temp.dat. (Statement 2)
(iii) Which statement should Aryan fill in Statement 3 to read the data from the binary
file,record.dat and in Statement 4 to write the updated data in the file, temp.dat?
P a g e 13 |
7