0% found this document useful (0 votes)
7 views15 pages

Class XII - Computer Science QP 1

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)
7 views15 pages

Class XII - Computer Science QP 1

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/ 15

SALEM SAHODAYA SCHOOLS COMPLEX

Pre – Board Examination 2023 – 2024


Grade : 12 Time allowed: 3 Hours
Subject : Computer Science (083) Maximum Marks: 70
General Instructions:
 Please check this question paper contains 35 questions.
 The paper is divided into 4 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 2 questions (31 to 32). Each question carries 4 Marks.
 Section E, consists of 3 questions (33 to 35). Each question carries 5 Marks.
 All programming questions are to be answered using Python Language only.

Q.No Question Marks

SECTION - A
State True or False:
1 1
“Python has a set of keywords that can also be used to declare variables”

In a table in MYSQL database, an alternate key is a, which is not the


primary key of the table.

a. Primary Key
2 1
b. Foreign Key

c. Candidate Key
d. Alternate Key

What will the following expression be evaluated to in Python?

27 % 7 // (3 / 2)
3 1
a. 2 b. 2.0

c. 4.0 d. 4
4 Select the correct output of the code: 1

[1]
a = "assistance"
a = a.partition('a')
b = a[0] + "-" + a[1] + "-" + a[2]
print (b)

Options:
a. -a-ssistance
b. -a-ssist-nce
c. a-ssist-nce
d. -a-ssist-ance
Fill in the blank: For each attribute of a relation, there is a set of
permitted values, called the _______of that attribute.
5 1
a. cardinality b. degree

c. domain d. tuple
Kriya wants to send mail to her friend. Which type of protocol will be
used in this case?
6 1
a. SMTP b. FTP
c. POP d. HTTPS
Given the following dictionaries
dict_student = {"rno" : "53", "name" : ‘Rajveer Singh’}
dict_marks = {"Accts" : 87, "English" : 65}
Which statement will merge the contents of both dictionaries?
7 1
a. dict_student + dict_marks
b. dict_student.add(dict_marks)
c. dict_student.merge(dict_marks)
d. dict_student.update(dict_marks)
Consider the statements given below and then choose the correct
output from the given options:
8 1
a= "Year 2022 at All the best"

a = a.split('2')
[2]
b = a[0] + ". " + a[1] + ". " + a[3]

print (b)

a. Year . 0. at All the best


b. Year 0. at All the best
c. Year . 022. at All the best
d. Year . 0. at all the best

Which of the following statement(s) would give an error during execution of


the following code?
S="Welcome to class XII" # Statement 1
print(S) # Statement 2
S="Thank you" # Statement 3
S[0]= '@' # Statement 4
S=S+"Thank you" # Statement 5
9 1
Options:

a. Statement 3

b. Statement 4

c. Statement 5

d. Statement 4 and 5

What possible output(s) are expected to be displayed on screen at the time of


execution of the program from the following code?

import random
10 1
points=[20,40,10,30,15]
points=[30,50,20,40,45]
begin=random.randint(1,3)
last=random.randint(2,4)

[3]
for c in range(begin,last+1):
print(points[c],"#")

Options:
a. 20#50#30#
b. 20#40#45
c. 50#20#40#
d. both (b) and (c)
Which switching technique follows the store and forward mechanism?

a. Circuit switching

b. message switching
11 1
c. packet switching

d. All of these

What is the output of the following code?


a=[1,2,3,4,5]
for i in range(1,5):
a[i-1]=a[i]
for i in range(0,5):
print(a[i],end=" ")
12 1

a. 5 5 1 2 3
b. 5 1 2 3 4
c. 2 3 4 5 1
d. 2 3 4 5 5

State whether the following statement is True or False:


13 1
-88.0 is the output of the print(3-10**2+99/11)

14 Which of the following statements is True? 1

[4]
a. There can be only one Foreign Key in a table.

b. There can be only one Unique key is a table

c. There can be only one Primary Key in a Table


d. A table must have a Primary Key.
What is the size of IPv4 address?
a. 32 bits
15 b. 64 bits 1
c. 64 bytes
d. 32 bytes
The readlines() method returns ____________

a. str
16 b. a list of lines 1

c. a list of single characters


d. a list of integers
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
Assertion(A): If L is a list, then L+=range(5)is an invalid statement.
17 1
Reasoning(R): Only a list can be concatenated to a list.
Assertion(A): In a function header, any parameter cannot have a default
18 value unless all parameters appearing on its right have their default values.. 1
Reasoning(R): Non- default arguments cannot follow default arguments.
SECTION - B
(i) Expand the following terms:

19 SLIP , PPP 1+1=2

(ii) Give one difference between LAN and MAN.


[5]
OR

(i) Define the term NIC with respect to networks.

(ii) How is http different from https?

The code given below accepts a number as an argument and returns the
reverse number. Observe the following code carefully and rewrite it after
removing all syntax and logical errors. Underline all the corrections made.

a=5
work=true
20 2
b=hello
c=a+b
FOR i in range(10)
if i%7=0:
continue

Write a function called letter_freq(my_list) that takes one


parameter, a list of strings(mylist) and returns a dictionary where the keys
are the letters from mylist and the values are the number of times that letter
appears in the mylist, e.g.,if the passed list is as:
wlist=list(“aaaaabbbbcccdde”) then it should return a
21 dictionary as{‘a’:5,’b’:4,’c’:3,’d’:2,’e’:1} 2

OR
Write a function called rem_keys( D,keylist) that accepts two
parameters: a dictionary called D and a list called keylist. Function
rem_keys(D,keylist) should remove all the keys contained in the
passed keylist from the dictionary D and return the dictionary.
Predict the output of the following code:
22 2
t1=("Sahodya",[1,2,'3'],'S',(3,4,6),"Exam",10)

[6]
print(t1[-5:-3]+t1[3])

Answer the following questions from the following code:


num_list=[“One”,”Two”,”Three”,”Four”]
for c in num_list:
print(c):

(i) What will be the output of the above code?

23 (ii) How many times the loop executed? 1+1=2

OR

A list named studentAge stores age of students of a class. Write the


Python command to import the required module and (using built-in function)
to display the most common age value from the given list.

What are aggregate and scalar functions in MYSQL? Give one example for
each
OR
a. Sonal needs to display name of teachers, who have “0” as the third
character in their name. She wrote the following query.
24 2

SELECT NAME FROM TEACHER WHERE NAME = “$$0?”

b. What are constraints in SQL? Give two examples.

Predict the output of the following code:


str1=list("Xy82")
25 2
for i in range(len(str1)):

[7]
if i==3:

x=int(i)

x+=x-3

str1[i]=x

elif (str1[i].islower()):

str1[i]=str1[i].upper()

else:

str1[i]=str1[i]*2

print(str1)

SECTION - C
Predict the output of the Python code given below:
z= 100

def f( ):

global z

print('z is:', z)
26 3
z=50

print('New value of global z is:', z)

f( )

print('Value of z is:', z)

[8]
27 1*3=3

Consider the above table CLUB, COACHES given below and write the
output of the SQLqueries that follow.

(i) SELECT AVG(PAY) FROM CLUB WHERE SPORTS=”KARATE”;


(ii) (a) SELECT MIN(AGE) FROM CLUB WHERE SEX=”F”;
(b) SELECT COUNT(DISTINCT SPORTS) FROM CLUB;
(iii) SELECT SPORTSPERSON, COACHNAME FROM CLUB,
COACHES WHERE CLUB.COACH_ID=COACHES.COACH_NO;
Write a method COUNT_DO( ) to count the presence of a word ‘do’ in a
text file “MEMO.txt”
Example:
If the content of the file is:
I will do it, if you request me to do it.
It would have been done much earlier.
28 3
Output should be : 2
Note: In the above example, ‘do’ occurring as a part of the word done is not
considered.
OR

[9]
Write a method countcap( ) in python to count the number of upper case
alphabets present in a text file “ARTICLE.txt”
Example :
If the file contains the given below content:
A piece of writing other than fiction or poetry that forms a separate part of
a publication (as a Magazine or Newspaper)
Then the countcap( ) has to give output as :
The number of capital case alphabets are : 3
Consider the table Store given below:

29 1*3=3
Based on the given table, write SQL queries for the following:
(a) Identify the attribute best suitable to be declared as primary key
(b) Write the query to add the row with following details
(2010,”Notebook”,23,155)
(c) (i) Now Abhay wants to display the structure of the table STORE i.e.
name of the attributes and their respective data types that he has used in the
table. Write the query to display the same.
(ii) Abhay wants to remove the table STORE from the database MyStore,
Help Abhay in writing the command for removing the table STORE from
the database MyStore.

Arr is a list of numbers. Write a function PUSH(Arr), to push all numbers


30 3
divisible by 5 from the list Arr to the stack. Display the stack if it has at

[10]
least one element otherwise display an appropriate message.

OR

Write a function in Python, Push(Player) where , Player is a


dictionarycontaining the details of stationary items– {Game:name}.

The function should push the names of those payers into the stack where the
name starts with letter ‘R’. Also display the count of elements pushedinto the
stack.

For example:

If the dictionary contains the following data:

Players={"Cricket": “RahulDravid”,"Chess": “R Pragnananda “, "Kho-Kho":


“Sarika Kale”,

"Kabaddi": “Pardeep Narwal”}

The stack should contain:

RahulDravid

R Pragnananda

The output should be:

The count of elements in the stack is 2

SECTION - D

Consider the following tables ACTIVITY and COACH. Write SQL


31 commands for the statements (i) to (iv) 1*4=4

Table: ACTIVITY

[11]
Write SQL queries for the following:

(i) To display the name of all activities with their Acodes in descending
order.

(ii) To display sum of prizemoney for each of the number of participants


groupings (as shown in column ParticipantsNum 10,12,16)

(iii) To display the coach’s name and ACodes in acending order of ACode
from the table COACH.

(iv) To display the content of the Activity table whose ScheduleDate is


earlier than 01/01/2004 in ascending order of ParticipantsNum.
Sharadhi Patel of class 12 is writing a program to create a CSV file
“emp.csv” which will contain employee code, name and salary of
employees. Write a Program in Python that defines and calls the
following user defined functions:
(i) InsRec() – To accept and add data of an employee to a CSV file

32 ‘emp.csv’. Each record consists of a list with field elements as eid, 4


ename and sal
(ii) search()- To display details of all the employees whose salary is
greater than 10000

As a programmer, help him to successfully execute the given task.

[12]
SECTION - E
Ravya Industries has set up its new center at Kaka Nagar for its office and
web based activities. The company compound has 4 buildings as shown in
the diagram below:

33 1*5=5

(i) Suggest a cable layout of connections between the buildings.


(ii) Suggest the most suitable place (i.e. building) to house the server of
this organisation with a suitable reason.
(iii) Suggest the placement of the following devices with appropriate
reasons:
a. Hub / Switch b. Repeater
(iv) The organisation is planning to link its sale counter situated in various
parts of the same city, which type of network out of LAN, MAN or WAN
will be formed? Justify your answer.
(v) Suggest a device/software to be installed in the Campus to take care of
data security.

[13]
A binary file “STUDENT.DAT” has structure (admission_number,
Name, Percentage).
Write a function addrec() in Python that would read contents of
the file “STUDENT.DAT”
Write function countrec() to display the details of those students
whose percentage is above 75. Also display number of students scoring
above 75%

OR
34 5
A binary file “BOOK.dat” has structure [BookNo, Book_Name, Author,
Price]

Write a user defined function Createfile( ) to input data for a record and
add to Book.dat

Write a function Countrec(Author) in python which accepts the Author


name as parameter and count and return number of books by the given
Author are stored in the binary file “Book.dat”

i) What is the role of a cursor? Write syntax to create a cursor?

ii) What is resultset? Write code to execute the query “Select * from student”
and store the retrieved record in the cursor object after creating cursor.

OR

35 a) Differentiate between fetchone() and fetchmany(). 5

b) Consider the following python and MySql connectivity code and


answer the following questions:
import mysql.connector
mydb=mysql.connector.connect(host="localhost",user="root",passw
d="12345",database= "student")
[14]
if mydb.is_connected()==True:
print("connection ok")
else:
print("error connecting to mysql database")
mycursor=mydb.cursor()
r=int(input("enter the rollno"))
n=input("enter name")
m=int(input("enter marks"))
mycursor.execute("INSERT INTO student(rollno,name,marks)
VALUES({},'{}',{})".format(r,n,m)) mydb.commit()
print(mycursor.rowcount,"RECRD INSERTED")

(i) Which of the following statement is connecting database server?


(ii) What is the purpose of the ‘cursor.rowcount in the following print
statement. print(mycursor.rowcount,"RECRD INSERTED")
(iii) What is the purpose of ‘mydb.commit()’ ?

[15]

You might also like