0% found this document useful (0 votes)
56 views9 pages

Practice Paper Solved Hy 12 2023

Uploaded by

aanchal.singhal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views9 pages

Practice Paper Solved Hy 12 2023

Uploaded by

aanchal.singhal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

SOLVED PRACTICE PAPER

Half Yearly Examination 2023-2024


Class 12 Computer Science (083)
Time allowed: 3 Hours Maximum Marks: 70
General Instructions:
● Please check this question paper containing 35 questions.
● The paper is divided into 5 Sections- A, B, C, D and E.
● Section A, consists of 18 questions (1 to 18). Each question carries 1 Mark.
● Section B, consists of 7 questions (19 to 25).Each question carries 2 Marks.
● Section C, consists of 5 questions (26 to 30). Each question carries 3 Marks.
● Section D, consists of 3 questions (31 to 33). Each question carries 5 Marks.
● Section E, consists of 2 questions (34 to 35). Each question carries 4 Marks.
● All programming questions are to be answered using Python Language only.
QNo Question Marks
SECTION A

1 Statement given below is True or False: 1


“print( type('True')) will return <class 'bool'>”

Ans False

2 Which of the following is a DML command of MySQL? 1


a. ALTER
b. DELETE
c. CREATE
d. DROP

Ans b. DELETE

3 What will be the output of the following statement? 1


print(4+3*5//3-5%2)

Ans 8

4 Select the correct output of the code: 1


def Exec(A=50,B=25):
A+=B
B+=A
print(A,B,sep="&")
P=10;Q=100
Exec(B=P,A=Q)
a. 120&110
b. 11&12
c. 110&120
d. 10&100

Ans c. 110&120

5 For the given function definition 1


def AddValues(a,b=10,c=20):

Which of the following is an incorrect function call in Python?


a. AddValues(5)
b. AddValues()

Page 1 of 9
c. AddValues(5,15)
d. AddValues(5,15,25)

Ans b. Addvalues()

6 Which of the following is an example of mutable Object type in Python? 1


a. List
b. String
c. Tuple
d. Int

Ans a. List

7 What will be the output of the following code: 1


s1="Class12"
s2="12"
print(s1.isdigit(),s2.isdigit())
a. True True
b. False False
c. True False
d. False True

Ans d. False True

8 What shall be the output of the following Python code on execution: 1

QUOTE=["TODAY","IS","WEDNESDAY"]
print(QUOTE[2][::-1])

a. YADSENDEW
b. TI
c. YADOT
d. IS

Ans a. YADSENDEW

9 Which of the following statement(s) would give an error during execution of the 1
following code?

city=['Delhi','Mumbai'] #Statement 1
print(city*2) #Statement 2
print(city+'Chennai') #Statement 3
city+=['Kolkata'] #Statement 4

Options:
a. Statement 1
b. Statement 2
c. Statement 3
d. Statement 4

Ans c. Statement 3

10 Consider the code given below: 1

import pickle
def Insert( ):
F=open("School.dat","wb")
pickle.________(['DPS',"RKP",12],F) # Missing Statement

Page 2 of 9
F.close()
Insert()

Which of the following statements should be given in the blank for #Missing
Statement

a. write
b. dump
c. writer
d. writerow

Ans b. dump

11 What is the datatype of the variable DATA in the following statement ? 1


DATA=f.readline()
a. list
b. tuple
c. string
d. dictionary

Ans c. string

12 Which of the following is not a valid datatype in SQL: 1


a. CHAR
b. DATE
c. INT
d. STRING

Ans d. STRING

13 The method of csv used to read the Python object from an opened CSV file is 1
a. load()
b. reader()
c. read()
d. dump()

Ans b. reader

14 Which of the following statements is NOT TRUE about a relational database? 1


a. Every value in a relation is atomic - i.e. it cannot be further divided
b. Names of columns are distinct
c. The rows in the relation are not ordered
d. The columns in the relation are always ordered

Ans d. The columns in the relation are always ordered

15 SELECT__________ FROM STUDENT ; 1


Which of the following counts all rows including the NULL value in one of the columns
using the above SELECT Query?
a. COUNT(Name)
b. COUNT(Class)
c. COUNT(*)
d. COUNT(DOB)

Ans c. COUNT(*)

Page 3 of 9
16 L = ['ONE', 'TWO', 'THREE'] 1
print(max(L))
What will be the output of the above statement?

a. ONE
b. TWO
c. THREE
d. 3

Ans b. TWO

Q17 and Q18 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

17 Assertion (A): Default value is assigned to parameters in the function header of a 1


function definition
Reasoning (R): Default parameter(s) can not be before non-default parameters.

Ans (a)

18 Assertion (A): UPDATE is a DDL command. 1


Reasoning (R): It is used to change a data value in a Table.

Ans (d)

SECTION B

19 Write the output on execution of the following code: 2


def power(a,b=2):
r=1
for i in range(b):
r=r*a
return r

print(power(4))
print(power(4,3))

Ans 16
64

20 Write the output on execution of the following code: 2


L=['A','B','C','D']
N=10
for i in range(len(L)):
L[i]+=str(N)
N-=2
print(L)

Ans ['A10', 'B8', 'C6', 'D4']

21 Write the output on execution of the following code: 2


t=('2','4','6','8')
s=0
for i in t:
Page 4 of 9
s+=int(i)
print(s)

Ans 20

22 Write the output on execution of the following code: 2


A=10;
def NewNum():
global A
B=20
A+=B+20
print(A)

NewNum()
A+=10
print(A)

Ans 50
60

23 Write the output on execution of the following code: 2


def Result(ST):
S={}
for k,v in ST.items():
if v>=90:
S[k]=v
return S
Names={"Anu":67,"Raj":98,"Ken":45,"Ram":92}
Res=Result(Names)
print(Res)

Ans {'Raj': 98, 'Ram': 92}

24 Anuradha has created databases and tables for her RDBMS. Help her do the following 2
tasks by giving her the SQL query :
a. To open the database- ORGANISATION so that she can work in it.
b. To display the list of the tables created in database- ORGANISATION.

Ans USE ORGANIZATION;


SHOW TABLES;

25 James created a CUSTOMER table and added 10 records in it. Later he realized he 2
forgot to add the PRIMARY KEY in the table. Give an SQL query
a. To add PRIMARY KEY CONSTRAINT in the CUSTOMER table.
b. Display the structure of the table to see the changes done.

Ans ALTER TABLE CUSTOMER ADD PRIMARY KEY (CID);


DESCRIBE CUSTOMER;

SECTION C
26 Write the output on execution of the following code: 3

def newvalue(M):
for i in range(len(M)):
First = M[i]-1
Sec = M[i]-2
Third=M[i]-3
print(First,Sec,Third,sep="#")

Page 5 of 9
L=[10,20,30]
newvalue(L)

Ans 9#8#7
19#18#17
29#28#27

27 Write a function definition for a function named SaveNew(T), which takes Tuple T as a 3
parameter. The function saves the str value in L1 and int values in L2 of the given
tuple.
For example :
if T=("story",34,True,10,20,"cloud",17.5)
Output:
L1=["story","cloud"]
L2=[34,10,20]

Ans def SaveNew(T):


L1=[];L2=[]
for t in T:
if type(t)==str:
L1.append(t)
else:
L2.append(t)
print(L1)
print(L2)

28 Find the errors in the program below and rewrite the program after correcting the 3
errors and underline the corrections.

def AddNum(x,y)
for i in range(1;y):
print(x)
12=a
C=input(int("enter a number"))
AddNum(a:b)
print(a,b,sep=%)

Ans def AddNum(x,y): # Error 1


for i in range(1,y): # Error 2
print(x)
a=12 # Error 3
C=int(input("enter a number")) # Error 4
AddNum(a,b) # Error 5
print(a,b,sep="%") # Error 6

29 Give the output of the SQL commands based on the table EMPLOYEE given below: 3

EMPNO NAME DEPT SALARY


E625 Sunil Accounts 1500
E421 Ajay Sales 2000
E121 Mary Manager 4500
E711 Mahir Accounts 2500
E423 Shamla Accounts 2000
E511 Vishal Manager 4300

a. SELECT DEPT, COUNT(*) FROM EMPLOYEE GROUP BY DEPT;


b. SELECT DEPT, NAME FROM EMPLOYEE WHERE NAME LIKE '%a_'
c. SELECT DISTINCT DEPT FROM EMPLOYEE
Page 6 of 9
Ans a.
Accounts 3

Sales 1

Manager 2
b.
Sales Ajay

Manager Vishal
c.
Accounts

Sales

Manager

30 Referring to the table given in the Question 29, write the queries for the following: 3
a. Insert a new row with values
('E213', 'Smith', 'Sales', 3400).
b. Remove those rows where the SALARY is less than 1500
c. Change the SALARY of 'Ajay' by an increase of 10%

Ans a. INSERT INTO EMPLOYEE


VALUES ('E213', 'Smith', 'Sales', 3400);
b. DELETE FROM EMPLOYEE WHERE SALARY<1500;
c. UPDATE EMPLOYEE SET SALARY=SALARY*1.10 WHERE NAME="Ajay";

SECTION D
31 Write a python function UpdateStock() to read content from a binary file “Stock.dat” 5
containing Itemno, Name and Quantity of Stock and increase the Quantity by 100 of all
such stocks where the quantity is less than 50.

Ans def UpdateStock():


with open("STOCK.DAT","rb+") as F:
ALL= pickle.load(F)
for I in range(len(ALL)):
if ALL[I][2]<50:
ALL[I][2]=ALL[I][2]+100
F.seek(0)
pickle.dump(ALL,F)

32 A CSV file named "FRIENDS.CSV" has to store the data of friends with the following 5
details :
● Name (string)
● School (String)
● Phone (integer)

a. Write a user defined function AddNew() to add the data of friends in the
above mentioned file. The process should continue till the user wants.
b. Write a user defined function Display() to display the details of those friends
whose Name starts with letter 'A'
Write a Menu Driven Program to access the above functions.

Page 7 of 9
Ans def AddNew():
with open("FRIENDS.CSV","w") as F:
CF=csv.writer(F)
while True:
Name=input("Name:")
School=input("School")
Phone=int(input("Phone"))
CF.writerow([Name,School,Phone])
More=input("More(Y/N)?")
if More in 'nN':
Break
def Display():
with open("FRIENDS.CSV","r") as F:
CF=csv.reader(F)
for C in CF:
if C[1][0]=='A':
print(C)

33 a. Answer the questions based on the table SHIPPING given below: 2


i. Identify the Degree and Cardinality.
ii. Identify the Primary Key and the Alternate Key

SHIPPING_ID STATUS CUSTOMER_ID


S01 PENDING C101
S02 PENDING C145
S03 DELIVERED C101
S04 RETURNED C342
S05 DELIVERED C145

b. Differentiate between the following : 3


i. DDL and DML commands
ii. ALTER and UPDATE
iii. WHERE and HAVING

Ans a. i. Degree: 3 Cardinality: 5


ii. Primary Key: SHOPPING_ID Alternate Key: CUSTOMR_ID
b. i. DDL - Data Definition Language
DML - Data Manipulation Language
ii. ALTER - To modify structure of a table
UPDATE - To modify the content (data) of a table
iii.WHERE - used for simple conditions such as Rno<90
HAVING- used for conditions on groups such as COUNT(*)<2

SECTION E
34 Write the SQL queries based on the table ORDERS given below: 4
ORD_ID ITEMNAME QUANTITY PRICE CUSTOMER_ID

78 KEYBOARD 12 2000 C101

36 MOUSE 15 1500 C123

25 KEYBOARD 10 2100 C324

Page 8 of 9
56 MONITOR 5 3400 C180

41 MOUSE 18 1600 C210

a. To display ITEMNAME, QUANTITY, PRICE of all orders whose price is above 2000.
b. To display QUANTITY and PRICE calculated as AMOUNT of all orders.
c. To display MAXIMUM of QUANTITY and MINIMUM of PRICE of all the orders
d. To display all records in the ascending order of PRICE

Ans a. SELECT ITEMNAME, QUANTITY, PRICE FROM ORDERS WHERE


PRICE>2000;
b. SELECT QUANTITY*PRICE AMOUNT FROM ORDERS;
c. SELECT MAX(QUANTITY),MIN(PRICE) FROM ORDERS;
d. SELECT * FROM ORDERS ORDER BY PRICE;

35 Write a function Alternate() in Python, which should display alternate lines of a text 4
file TIGER.TXT, starting with the first line of the file.

Example:
If the file content is as follows:
There is a tiger in the woods
Looking for its prey, so pray
Soon will be injurious what was once good
Ready and steady he sets about to slay
The brave who protrude along his way

The Alternate() function should display the output as:


There is a tiger in the woods
Soon will be injurious what was once good
The brave who protrude along his way

Ans def Alternate():


with open("TIGER.TXT") as F:
LINES=F.readlines()
for i in range(len(LINES)):
if i%2==0:
print(LINES[i])
OR

def Alternate():
with open("TIGER.TXT") as F:
LINES=F.readlines()
for L in LINES[::2]:
print(L)

Page 9 of 9

You might also like