Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Pyq 1987

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

SAMPLE QUESTION PAPER – 8 2022-23

CLASS- XII
Time: 3hrs COMPUTER SCIENCE (083) Max. Marks: 70

General Instructions:
1. This question paper contains five sections, Section A to E.
2. All questions are compulsory.
3. Section A have 18 questions carrying 01 mark each.
4. Section B has 07 Very Short Answer type questions carrying 02 marks each.
5. Section C has 05 Short Answer type questions carrying 03 marks each.
6. Section D has 03 Long Answer type questions carrying 05 marks each.
7. Section E has 02 questions carrying 04 marks each. One internal choice is given in Q35
against part c only.
8. All programming questions are to be answered using Python Language only.

SECTION-A
(1 mark to be awarded for every correct answer)
01 Write the names of the following Tokens of Python : 1
(i) if (ii) roll_no
02 Identify the valid Logical operator in Python from the following. 1
(a) OR (b) != (c) in (d) and
03 Suppose a tuple T is declared as T = (25, 37, 58, 79), which of the following is 1
incorrect?
a) print(T[1]) b) T[2] = –96
c) print(max(T)) d) print(len(T))

04 Consider the given expression: 1


20<30 and 15>7 or not 25<4
Which of the following will be correct output if the given expression is
evaluated?
(a) True
(b) False
(c) NONE
(d) NULL
05 Select the correct output of the code: 1
s = "Python4 4.0 Programming Language."
s1 = s.split('4')
s2 = s1[0] + ". " + s1[1] + ". " + s1[2]
print (s2)

(a) Python. 0. Programming Language.


(b) Python. . .0 Programming Language.
(c) Python. .0 . Programming Language.
(d) Python0 Programming Language
06 Which of the following options can be used to read the first line of a text file 1
Myfile.txt?
a. myfile = open('Myfile.txt'); myfile.read()
b. myfile = open('Myfile.txt','r'); myfile.read(n)
c. myfile = open('Myfile.txt'); myfile.readline()
d. myfile = open('Myfile.txt'); myfile.readlines()

07 Which command is used to view the list of tables in a database? 1


(a) alter (b) show tables (c) view tables (d) show databases

08 ALTER TABLE is a ___________ category of SQL command. 1

a) TCL b) DML c) DCL d) DDL


09 Identify the output of the following python statements if there is no error. 1
Otherwise, identify the error(s):

(a) ['0', '2', '0', '2'] # 4


(b) ['r', '2', '0', '2',’0’] # 4
(c) ['2', '0', '2', '0'] # 4
(d) ['2', '0', '2', '0'] # 5
10 Which of the following types of table constraints will prevent the entry of 1
duplicate rows?
a) Check
b) Distinct
c) Primary Key
d) NULL
11 Syntax of seek function in Python is myfile.seek(offset, reference_point) where 1
myfile is the file object. What is the default value of reference_point?
a)2
b) 1
c)0
d) 3
12 Fill in the blanks : 1
____________ statement is used to remove all records of a table “BACKUP”
along with its structure to release the storage space.
a) DELETE TABLE BACKUP;
b) DROP TABLE BACKUP;
c) ALTER TABLE BACKUP;
d) REMOVE TABLE BACKUP;
13 Fill in the blank: 1
______is a program used for sending messages to other computer users based
on e-mail addresses.
(a) IMAP(b) SMTP (c) FTP(d)HTTP

14 What will the following expression be evaluated to in Python? 1


print( 6 * 3 + 4**2 // 5 – 8)
(a) 13.2(b)14.0 (c) 13(d) 11

15 Which of the following aggregate function does not ignore nulls in its results? 1

(a) COUNT (b) COUNT(*) (c)MAX( ) (d) MIN( )


16 To run an SQL query from within Python, you may use 1
<cursor_object>.________.
(a) query( ) (b)fetchall( )(c)run() (d) execute( )
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

17 Assertion : A function can be called with keyword argument. 1


Reasoning: While calling a function with keyword argument parameter
sequence is not mandatory.

18 Assertion (A):The dump( ) method is used to write data in a binary file. 1


Reason (R):To use dump( ) , we must import the csv module .

SECTION-B
19 Saroj has written a Python code . His code is having errors. Rewrite the correct 2
code and underline the corrections made.

def evaluate( ) :
Value=30
for val in range(0,Value)
If val%4==0:
print (VAL*4)
Elseif val%5=0:
print (VAL+3)
else
print(VAL+10)

20 Write two points of difference between Circuit Switching and Packet Switching. 2
OR
Write two points of difference between Hackers and Crackers.

21 (a) Given is a Python string declaration: (01) 2

msg = “Hello Friends”

Write the output of: print(msg [ : : -1])


(b) Write the output of the code given below: (01)
pr_dict = {"myname": "Ranjan", "address": “BBSR”}
pr_dict['age'] = 19
pr_dict['address'] = "Cuttack"
print(pr_dict.items())

22 Explain the Candidate Key in a Relational Database Management System. Give 2


an example to support your answer.

23 (a) Write the full forms of the following: 2


(i) IMAP
(ii) VoIP

(b) Which protocol helps us to transfer files to and from a remote computer?

24 Find and write the output of the following python code: 2


Data = ["P",20,"R",10,"S",30]
Times = 0
Alpha = " "
Add = 0
for C in range(1,5,2):
Times= Times + C
Alpha= Alpha + Data[C-1]+"$"
Add = Add + Data[C]
print (Times, Add, Alpha)

“OR”

Predict the output of the Python code given below:


T = (77, 25, 35, 61, 55 ,97)
L =list(T)
N_list = []
for i in L :
if i%2==0:
N_list.append(i)
N_tuple = tuple(N_list)
print(N_tuple)

25 Differentiate between HAVING clause and WHERE clause in MySQL ? 2

“OR”

Categorize the following commands as DDL or DML:

DROP TABLE, SELECT, ALTER TABLE, UPDATE

SECTION-C
26 (a) Consider the following tables – Customer and City: (01) 3
Table: Customer
CID CNAME AMOUNT
1001 Mukesh 5000
1002 Kailash 4500
1003 Nitesh 6000

Table : City

CID CITY
1001 Rourkela
1002 Bhubaneswar
1001 Cuttack
What will be the output of the following statement?
SELECT * FROM Customer NATURAL JOIN City ;
(b)Write the outputs of the SQL queries (i) to (iv) based on the table given below:
(02)

(i) SELECT DISTINCT ANO FROM TRANSACT ;


(ii) SELECT ANO, COUNT(*), MIN(AMOUNT) FROM TRANSACT
GROUP BY ANO HAVING COUNT(*)> 1;
(iii) SELECT COUNT(*), SUM(AMOUNT) FROM TRANSACT
WHERE DOT <= '2017-06-01';
(iv) SELECT AVG(AMOUNT) FROM TRANSACT
WHERE ANO=103;
27 Write a method DISPLAY( ) in Python to read lines from a text file 3
DIARY.TXT, and display those lines, which are starting with an alphabet „P‟.
For example:
“Python is a high level programming language.
It is easy to learn.
Python language uses interpreter.
A language processor is also called a language translator.”
The output should be :
Python is a high level programming language.
Python language uses interpreter.
“OR”
Write a method in python to read lines from a text file INDIA.TXT, to find and
display the occurrence of the word “India”.
For example:
If the content of the file is
_________________________________________________________________
“India is the fastest growing economy. India is looking for more investments
around the globe. The whole world is looking at India as a great market. Most of
the Indians can foresee the heights that India is capable of reaching.”
_________________________________________________________________
The output should be 4

28 (a) Write the outputs of the SQL queries (i) to (iv) based on the relations 3
TRAINER and COURSE given below:

i) SELECT DISTINCT(CITY) FROM TRAINER WHERE SALARY>80000;


ii) SELECT TID, COUNT (*), MAX(FEES) FROM COURSE GROUP BY TID
HAVING COUNT (*)>1;
iii) SELECT T.TNAME, C.CNAME FROM TRAINER T, COURSE C WHERE
T.TID=C.TID AND C.FEES<10000;
iv) SELECT CITY, AVG(SALARY) FROM TRAINER
WHERE CITY=‟DELHI‟;

(b) Write a MySQL command to view the list of all databases.

29 Write a function SHOW_INDEX(Li), where Li is the list of elements passed as 3


argument to the function. The function returns another list named List_indices
that stores the indices of all negativeelements of Li.
For example:
If L contains [-65,4,0,-13 , 88 ,-33, -72]
The List_indices will have - [0,3,5,6]

30 Manoj has a list containing 10 integers. You need to help him create a program 3
with separate user defined functions to perform the following operations based on
this list.
● Traverse the content of the list and push the even numbers into a stack.
● Pop and display the content of the stack.

For Example:
If the sample Content of the list is as follows:
N=[12, 13, 34, 56, 21, 79, 98, 22, 35, 38]
Sample Output of the code should be:
38 22 98 56 34 12

“OR”
Julie has created a dictionary containing names and marks as key value pairs of 6
students. Write a program, with separate user defined functions to perform the
following operations:
● Push the keys (name of the student) of the dictionary into a stack, where the
corresponding value (marks) is greater than 75.
● Pop and display the content of the stack.

For example:
If the sample content of the dictionary is as follows:
R={"Niki":76, "Manu":45, "Bilu":89, "Ani":65, "Kanu":90, "Hok":82}
The output from the program should be:
NikiBiluKanuHok
SECTION-D
31 5
Intelligent Hub India is a knowledge community aimed to uplift the standard
of skills and knowledge in the society. It is planning to setup its training
centers in multiple towns and villages pan India with its head offices in the
nearest cities. They have created a model of their network with a city, a town
and 3 villages as given.
As a network consultant, you have to suggest the best network related solution
for their issues/problems raised in (i) to (v) keeping in mind the distance
between various locations and given parameters.
Shortest distance between various locations:

Number of computers installed at various locations are as follows:

Note:
• In Villages, there are community centers, in which one room has been given
as training center to this organization to install computers.
• The organization has got financial support from the government and top IT
companies.

I. Suggest the most appropriate location of the SERVER in the YHUB


(out of the 4 locations), to get the best and effective connectivity.
Justify your answer.
II. Draw the cable layout (location to location) to efficiently connect
various locations within the YHUB.
III. Which hardware device will you suggest connecting all the computers
within each location of YHUB?
IV. Which server/protocol will be most helpful to conduct live
interaction of Experts from Head office and people at YHUB
locations?
V. Suggest the best wired medium to efficiently connect various
locations within the YHUB

32 (a) Predict the output of the Python code given below: (02) 2+3=
5
def Diff(N1,N2):
if N1>N2:
return N1-N2
else:
return N2-N1
NUM= [10,23,14,54,32]
for CNT in range (4,0,-1):
A=NUM[CNT]
B=NUM[CNT-1]
print(Diff(A,B),'#', end=' ')
(b) The code given below inserts the following record in the table Employee:
EmpNo – integer (03)
EmpName – string
EmpDesig – string
EmpSalary – float
Note the following to establish connectivity between Python and MYSQL:
 Username is „root‟
 Host name is „localhost‟
 Password is „dav@123‟
 The table exists in a MYSQL database named STORE.
 The details (EmpNo, EmpName, EmpDesig,EmpSalary) are to be accepted
from the user.

Write the following missing statements to complete the code:


Statement 1 – to form the cursor object
Statement 2 – to execute the command that inserts the record in the table
Employee.
Statement 3- to add the record permanently in the table Employee.
import mysql.connector as mysql
def sql_data():
con1=mysql.connect(host="localhost",user="root", password="dav@123",
database="STORE")
mycursor=_________________ #Statement 1
EmpNo=int(input("Enter Employee Number :: "))
EmpName=input("Enter name :: ")
EmpDesg=input("Enter employee designation :: ")
EmpSalary=float(input("Enter Salary :: "))
querry="insert into student values({},'{}',‟{}‟,{})".
format (EmpNo,EmpName,EmpDesig,EmpSalary)
______________________ #Statement 2
______________________ # Statement 3
print("Data Added successfully")

“OR”

(a) Find and write the output of the following python code: (02)
Msg1="WeLcOME"
Msg2="GUeSTs"
Msg3=""
for I in range(0,len(Msg2)+1):
if Msg1[I]>="A" and Msg1[I]<="M":
Msg3=Msg3+Msg1[I]
elif Msg1[I]>="N" and Msg1[I]<="Z":
Msg3=Msg3+Msg2[I]
else:
Msg3=Msg3+"*"
print (Msg3)

(b) Meena wants to see all the records from the Traders table. (03)
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 .
Statement 3 – to read the complete result of the query .

import mysql.connector as db
mycon=db.connect(host=”localhost”,user=”system”,password=”test”,datab
ase=”Admin”)
cursor=___________________# statement 1
sql=”SELECT * FROM Traders “
______________________ # Statement 2
data=__________________ # Statement 3
for dt in data:
print(dt)
mycon.close()

33 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:

a. CSVOpen() : to create a CSV file called BOOKS.CSV in append mode


containing information of books – Title, Author and Price.

b. CSVRead() : to display the records from the CSV file called BOOKS.CSV
where the field title starts with 'R'.
“OR”
Give any one point of difference between a binary file and a text file.
Write a Program in Python that defines and calls the following user defined
functions:

a) ADD_DATA() – To accept and add data of an employee to a CSV file


„items.csv‟. Each record consists of a list with field elements as id, iname and
iprice to store item id, item name and item price respectively.

b) SEARCH()- To display the records of the items whose price is more than
25000.

SECTION-E
34 1+1+
2
=4
(c) and answer the questions (a) and (b)

(a) Identify the attribute best suitable to be declared as a primary key.


(b) Write the degree and cardinality of the Table GRADUATE.
(c) (i) To increase the stipend of PHYSICS students by 100.
(ii) Display the name of those students whose name starts with „D‟.
“OR”
(i) Display the details of all students who secured an average below 40.
(ii) Display the name of those students whose name ends with „A‟.
35 Amritya Seth is a programmer, who has recently been given a task to write a 1+1+
python code to perform the following binary file operations with the help of two 2
user defined functions/modules: =4
a. AddStudents() to create a binary file called STUDENT.DAT containing
student information – roll number, name and marks (out of 100) of each student.
b. GetStudents() to display the name and percentage of those students who
have a percentage greater than 75. In case there is no student having percentage >
75 the function displays an appropriate message. The function should also display
the average percent.

He has succeeded in writing partial code and has missed out certain statements,
so he has left certain queries in comment lines. You as an expert of Python have
to provide the missing statements and other related queries based on the
following code of Amritya.
Answer the below mentioned questions.
import _______________ # Statement 1
def AddStudents():
____________ # Statement 2 to open the binary file to write data
while True:
Rno = int(input("Rno :"))

You might also like