0% found this document useful (0 votes)
289 views33 pages

4th 5th and 6th Paper

The document discusses a sample paper for class 12 computer science subject. It contains instructions for the paper and sections from A to E containing different types of questions - very short answer, short answer, long answer and internal choice questions. Programming questions are to be answered using Python. Sections A contains 18 multiple choice questions of 1 mark each. Section B has 7 very short answer questions of 2 marks each. Section C has 5 short answer questions of 3 marks each. Section D has 3 long answer questions of 5 marks each. Section E has 2 questions with internal choice of 4 marks each.

Uploaded by

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

4th 5th and 6th Paper

The document discusses a sample paper for class 12 computer science subject. It contains instructions for the paper and sections from A to E containing different types of questions - very short answer, short answer, long answer and internal choice questions. Programming questions are to be answered using Python. Sections A contains 18 multiple choice questions of 1 mark each. Section B has 7 very short answer questions of 2 marks each. Section C has 5 short answer questions of 3 marks each. Section D has 3 long answer questions of 5 marks each. Section E has 2 questions with internal choice of 4 marks each.

Uploaded by

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

SAMPLE PAPER SET 4

CLASS – XII SUBJECT: Computer Science-083


Total Time- 3 Hours Total 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 Q34 against
part iii only.
8. All programming questions are to be answered using Python Language only.

SECTION A
1. Find the invalid identifier from the following 1
a) MyName b) True c) 2ndName d) My_Name
2. (Which of the following is a mutable datatype in Python? 1
(a) String (b) List (c)Integer (d) Tuple
3. Given the following dictionaries D1={"Exam":"ICSCE", 1
"Year":2023, "Total":500}
Which statement will add a new value pair (Grade: “A++”) in dictionary D1?
a. D1.update(“REMARK” : “EXCELLENT”)
b. D1 + {“REMARK” : “EXCELLENT”}
c. D1[“REMARK”] = “EXCELLENT”
d. D1.merge({“REMARK” : “EXCELLENT”})
4. Consider the given expression: 1
not False or False and True
Which of the following will be correct output if the given expression is evaluated?
(a) True b)False c)NONE d) NULL

5. Select the correct output of the code: 1


Str = "KENDRIYA VIDYALAYA SANGATHAN JAMMU REGION"
Str = Str.split()
NewStr = Str[0] + "#" + Str[1] + "#" + Str[4]
print (NewStr)

a) KENDRIYA#VIDYALAYA#SANGATHAN# JAMMU
b) KENDRIYA#VIDYALAYA#SANGATHAN
c) KENDRIYA#VIDYALAYA# REGION
d) None of these

1
6. Assume that the position of file pointer is at the beginning of 3rd line in a text file. 1
Which of the following option can be used to read all remaining lines?
(a) file.read() (b) file.readlines() (c) file.readline() (d) None of these
7. Fill in the blank: 1
command is used to change datatype of a field in table in SQL.
(a) update (b)remove (c) alter (d)drop
8. in a table represent relationship among a set of values. 1

(a) Column (b) Keys (c) Row (d) Entry


9. Which of the following statement(s) would give an error after executing the 1
following code?

P ="FIRST PRE BOARD" # Statement 1 print(P) #


Statement 2
P = P[1:7] + "Questions" # Statement 3
P[0] = '&' # Statement 4
P =P + "Over" # Statement 5

(a) Statement 3 b) Statement 4


(c) Statement 5 d) Statement 4 and 5

10. Fill in the blank: 1


is a set of one or more attributes, which can uniquely identify any tuple in
a relation.
a) Primary Key b) Foreign Key c) Candidate Key d) Alternate Key

11. The method of module is used to read data from binary file : 1
a) read(), binary b) load(), pickle
c) dump(), binary d) dump(), pickle
12. Which keyword can be used to show only different values in a particular 1
column in a table?
a) DESCRIBE b) DISTINCT c) UNIQUE d)NULL
13. Fill in the blank: 1
Which of the following statement are true about URL?

(a) URLmeans Uniform Resource Locator b) Wecanenter URLintoaddressbar


(c) Anexampleof [email protected] (d) Both Aand B
14. What will the following expression be evaluated to in Python? 1
print(75.0 / 4 + (2** 3))
(a) 20.5 (b)20.05 (c) 18.25 (d) 17.75

15. Which function is used to display the Smallest largest value from the selected column of 1
table in a database?
a) Small() b) Least() c) Min() d) None of above()

16. To establish a connection between Python and MySQL database, which of the following 1
method is used?
a) connector() b) connect() c) cont() d) con()

2
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):- Keyword arguments are related to function call statement. 1
Reasoning (R):- When we use keyword argument in a function call, the caller
identifies the argument by the parameter.
18. Assertion (A): CSV (Comma Separated Values) stands for Comma Separated values File. 1
Reason (R): CSV files are common file format for transferring and storing data.

SECTION
B
19. Correct Code is 2
def DigitSum():
n = int( input("Enter number :: ")
dsum = 0
while n > 0 d
= n % 10
dsum =dsum + d n
= n //10
RETURN dsum
20. What is an E-mail? Write two advantages of an E-mail. 2
OR
Write two points of difference between Bus topology and Star topology.

21. (a) Given is a Python string declaration: 1


Word = "Connect Python”
Write the output of: print(Word[: : 3])
(b) Write the output of the code given below:
dict = {"Item": "Laptop", "Make": "LG" }
dict["Price"] = 57000 1
dict["Make"] = "DELL"
for k in dict:
print(k, ‘@’, dict[k])
22. What do you mean by Candidate Key in Relational Database Management System. Also 2
define Alternate Key.
23. (a) Write the full forms of the following: 2
(i) CDMA (ii) VOIP
(b) What is Web browser? Give name of two commonly used web browsers.

3
24. Predict the output of the Python code given below: 2

L1 =[]
def display(N): for K in
N:
if K % 2 ==0:
L1.append(K//2) else:
L1.append(K*2) L =
[11,22,33,45,55,66]
print(L) display(L)
print(L1)
OR
Predict the output of the Python code given below:

T1 = (12, 22, 33, 55 ,66)


list1 =list(T1)
new_list = [] for i in
list1: if i%3==0:
new_list.append(i) new_T
= tuple(new_list)
print(new_T)

25 Differentiate between WHERE and HAVING clause in SQL with appropriate example. 2
. OR
Write any Two DDL and Two DML commands.
SECTION C
2 A Stationery shop MyBag has decided to maintain its inventory of items using MySQL. As a 1+
6 database administer, Rahul has created the database and table as per the following : 2
Name of the database -MyBag Name
of the table - ITEMS
The attributes of ITEMS are as follows: ItemNo – Numeric, ItemName – Character of size 20
,Scode –Numeric,Quantity –Numeric
ITEMS
ItemNo ItemName Scode Quantit y
2005 Sharpener Classic 23 60
2002 Get Pen Premium 21 150
2006 Get Pen Classic 21 250
2001 Eraser Small 22 220
2004 Eraser Big 22 110
a. Identify the best suitable attribute to be declared as a primary key.
b. Insert the following data into the attributes ItemNo, ItemName and SCode
respectively in the given table ITEMS.
ItemNo = 2010, ItemName = “Note Book” , Scode = 25 and Quantity=50
c. Rahul wants to display all the records where ItemName starts with ‘G’. Write
a MySQL query to do the same.

4
27 Write a function in Python to read from a text file “INDIA.TXT”, to find and display those 3
words of file which have 3 characters. For example, If the “INDIA.TXT” contents are as
follows:
“India is the fastest growing economy.
India is looking for more investments around the globe.”
The output of the function should be: the for the

28 a) Write the outputs of the SQL queries (i) to (iv) based on the relations 3
BOOK and ISSUES given below:
Table : Book
Quanti
Book_id Book name Author_name Publisher Price Type ty
C0001 Fast Cook Lata Kapoor EPB 355 Cookery 5
William
F0001 The Tears Hopkins First Pub 650 Fiction 20
T0001 My First c++ Brain & Brooke FPB 350 Text 10
C++ Brain
T0002 works A.W. Rossaine TDH 350 Text 15
F0002 Thunderbolts Anna Roberts First Publ. 750 Fiction 50
Table : issued
Book_Id Quantity Issued
T0001 4
C0001 5
F0001 2
i. Select Count(*) from Books
ii. Select Max(Price) from books where quantity >=15
iii. Select book_name, author_name from books where publishers=’First Publ.’
iv. Select a.book_id,a.book_name,b.quantity_issued from books a, issued b
where a.book_id=b.book_id

(b) Write the command to open a database “RAILWAY” in MySQL.


29. Write the definition of a function Reverse(X) in Python to display the elements in 3
reverse order such that each displayed element is twice of the original element
(element *2) of the List X in the following manner:
For example, if List X contains 7 integers as follows:

X [0] X[1] X[2] X[3] X[4] X[5] X[6]


4 8 7 5 6 2 10
After executing the function, the array content should be displayed as follows:
X [0] X[1] X[2] X[3] X[4] X[5] X[6]
20 4 12 10 14 16 8

5
30 Consider a binary file Employee.dat containing details such as 3
empno:ename:salary(separator ‘:’). Write a Python function Readfile() to display details of
those employees who are earning between 20000 and 40000(both values inclusive) also
count how many records are available in the file.
OR
A binary file named “TEST.dat” has some records of the structure [TestId, Subject,
MaxMarks, ScoredMarks]
Write a function in Python named DisplayAvgMarks(Sub) that will accept a subject as an
argument and read the contents of TEST.dat. The function will calculate & display the
Average of the ScoredMarks of the passed Subject on
screen.
SECTION D

31 Software Development Company has set up its new center at Raipur for its office and 5
web based activities. It has 4 blocks of buildings named Block A, Block B, Block C, Block
D.
No of Computers in each Block Distance between various blocks
Block A 25 Block A to Block B 60 Mtrs
Block B 50 Block B to Block C 40 Mtrs
Block C 125 Block C to Block A 30 Mtrs
Block D 10 Block D to Block 50 Mtrs
a) Suggest the most suitable place (i.e. block) to Chouse the server of this company
with a suitable reason.
b) Suggest the ideal layout to connect all the blocks with a wired connectivity.
c) Which device will you suggest to be placed/installed in each of these blocks to
efficiently connect all the computers within these blocks.
d) Suggest the placement of a repeater in the network with justification.
The company is planning to link all the blocks through a secure and
high speed wired medium. Suggest a way to connect all the blocks.

32 (a) Write the output of the code given below: 2+3

Find and write the output of the following python code: def
encrypt(s):
k=len(s)
m=""
for i in range(0,k):
if(s[i].isupper()):
m=m+str(i)
elif s[i].islower():
m=m+s[i].upper()
else:
m=m+'*'
print(m)

encrypt('KVS@Jammu')

(b) The code given below inserts the following record in the table Item:
6
ItemNo – integer Name –
string
Price – integer
Qty – integer

Note the following to establish connectivity between Python and MYSQL:


 Username is root
 Password is beeta
 The table exists in a MYSQL database named RESOURCE.
 The details (ItemNo, Name, Price and Qty) are to be accepted from the
user.
Write the following missing statements to complete the code:
Statement 1 – to import the required module
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 as mysql # Statement 1

def sql_data():
con1=mysql.connect(host="localhost", user="root",
password="omega", database="resource")
mycursor= con1.cursor()
ItemNo = int(input("Enter ItemNo :: "))
Name = input("Enter name :: ")
Price = int(input("Enter price :: "))
Qty = int(input("Enter Qty :: "))
querry="insert into student
values({}, '{}',{ }, {})".format(Itemno, Name, Price, Qty)
#Statement 2
# Statement 3
print("Data Added successfully")

OR
(a) Predict the output of the code given below:
s ="Back2Basic"
n = len(s)
NS =""
for i in range(0, n):
if (s[i] in “áeiou”):
NS = NS + s[i].upper()
elif (s[i] >= 'a' and s[i] <=
'z'):
NS = NS +s[i].lower()
else:
NS = NS + '#'
print(NS)

(b) The code given below reads the following record from the table named student
and displays only those records who have marks greater than 85:
RollNo – integer Name –
string Class – integer
Marks – integer
Note the following to establish conne7ctivity between Python and MYSQL:
 Username is root
 Password is tiger
 The table exists in a MYSQL database named
school. 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 85.
Statement 3- to read the complete result of the query (records whose marks are
greater than 85) into the object named data, from the table studentin the database.

import mysql.connector as

mysql def sql_data():


con1=mysql.connect(host="localhost",user="root", password="tiger",
database="school")
mycursor= #Statement 1
print("Students with marks greater than 85 are :")
#Statement 2
data = #Statement3
for i in data:
print(i)
print()
33. a) What do you mean by a csv file? 5
(1+2+2
b) A binary file “Book.dat” has structure [BookNo, Book_Name, Author, Price]. )
a) Write a user defined function CreateFile() to input data for a record and add
to Book.dat file.
b) Write a function CountRec(Author) in Python which accepts the Author name as
parameter and count and return number of books written by the given Author
are stored in the binary file “Book.dat”
OR

a) Difference between a binary file and a csv file.

b Write a function in python, pushme (stock, item) and popme(stock ) to add a


new item and delete an item from the stock, considering them to act as push and
pop operations of the stack.

SECTION E

8
34 Nawal Rao creates a table Emp 1+1+2

Emp Name Dept Design Gend Salary City


no er
1 Deepika Sales Mgr F 55000 Delhi
2 Gagan Acct Opt M 20000 Patna
3 Neelam Comp Opt F 25000 Delhi
4 Vijay Sales Mgr M 45000 Lucknow
5 Sunita Acct Opt F 14000 Delhi
6 Rajesh Sales Clrk M 35000 Patna
7 Kunal Comp Mgr M 40000 Lucknow
Based on the data given above answer the following questions:

(i) Identify the most appropriate column, which can be considered as


Primary key.
(ii) If one column is added and 2 rows are deleted from the table EMP, what
will be the new degree and cardinality of the above table?
(iii) Write the statements to:
a. Insert the following record into the table
EmpNo- 8, Name- Ravi, Dept- Sales, Design- Mgr, Gender- M, Salary –
34000, City- Delhi .
b. Increase the Salary of the Employees who are in Acct
department by 3%.
OR (Option for part iii only)
(iii) Write the statements to:
a. Delete the record of Employees who lives in Delhi.
b.Add a column MobNo in the table with datatype as
varchar with 10 characters
35 Aditya has written a code and created a binary file record.dat with ItemNo, Itname and
Price.
As a Python expert, help him to complete the following code based on the requirement
given above:

Import #Statement 1
def Add_data():
fin = open("record.dat", " ") #Statement2
Lst = [áa’, 3.5, 66,77, 8, 10]
.(Lst, fin) #Statement3
print(“Record Added”)
fin. #Statement4

Add_Rec()
1
a) Name the Module that Aditya should import in Statement 1
b) In which mode, Aditya should open the file to add data into the file in statement 1
2.
2
c) Fill in the blank in statement 3 to fetch the data to a file and statement 4 to close
the file.

9
SAMPLE PAPER SET 5

CLASS – XII SUBJECT: Computer Science-083

Total Time- 3 Hours Total Marks- 70

General Instructions:

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


2. All questions are compulsory.
3. Section A has 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
isgiven in Q35 against part c only.
8. All programming questions are to be answered using Python Language only.

Q1. Which is a valid identifier in python? 1


(a) int
(b) len
(c) ssum1
(d) all of them
Q2. Which type of Programming does Python support? 1
(a) object-oriented programming
(b) structured programming
(c) functional programming
(d) all of the mentioned
Q3 Which keyword is used for function in Python language? 1
(a) Function
(b) def
(c) Fun
(d) Define
Q4. Create the dictionary on data 1
Exam=”PB”
Year=”2013”
Where exam and year are keys

Q5. Consider the given expression: 1


not True and False or True
Which of the following will be correct output if the given expression is
evaluated?
(a) True
(b) False
(c) None
(d) NULL
Q6. What is the output of the following? 1
print('KV Sangathan'.split('an'))
(a) ['KV S', 'gath', ' ']
(b) [‘KV Sangathan’,’an’]
(c) [‘KV’,’Sang’,’athan’]
(d) All of them
Q7. Which of the following modes will refer to binary data? 1
(a) r
(b) wb
(c) +
(d) a
Q8. Fill in the blank: 1
command is used to remove the database in sql.
(a) Update
(b) Remove
(c) Drop
(d) alter
Q9. Which of the following commands will be delete the table from MYSQL 1
Database?
(a) Delete table
(b) Drop Table
(c) Remove Table
(d) Alter Table

Q10 If the following code is executed, what will be the output of the following code? 1
. name="Kendriya Vidyalaya Sangathan"
print(name[10:19])
(a) Kendriya
(b) Vidyalaya
(c) Sangathan
(d) nry iy
Q11 Which of the following types of table constraints will prevent the printing 1
.
of duplicate values after the Select statement fetches data from table?
(a) Unique
(b) Distinct
(c) Primary Key
(d) NULL
Q12 What is the use of tell () function in python 1
.
Q13 Switch is a 1
. A. Broadcast device B. Unicast device C. Multicast device D. None of the above
Q14 What will the following expression be evaluated to in python? 1
. print(15.0/4+(8*3.0))
(a) 14.5
(b) 14.0
(c) 27.7
(d) 15.5
Q15 Which function is used to display the sum of column of records from table in a 1
. database?
(a) sum(*)
(b) total(*)
(c) count(*)
(d) return(*)
Q16 What is the use of connect () function ? 1
.
Q17 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
(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):- If the arguments in function call statement match the 1
number and order of arguments as defined in the function definition,
such arguments are called positional arguments.
Reasoning (R):- During a function call, the argument list first contains
default argument(s) followed by positional argument(s).
Q18 Assertion (A): CSV (Comma Separated Values) is a file format for data storage 1
. which looks like a text file.
Reason (R): The information is organized with one record on each line and each
Section-B
Q19 Mr. Ram has written a code to input two numbers and swap the number using 2
. function but he has some error in his coding, so help him to rectify the errors
and rewrite the correct code.
Def swap(a,b)
c=a
a=b
b=c
print("a is",a,"b is",b )
#main()
a=int(input("enter in a "))
b=int(input("enter in b"))
Swap(a,b)#calling a function
Q20 What is the difference between a hub and a switch in context of computer 2
.
networking devices?
OR
Differentiate between HTTP and FTP.
Q21 Evaluate the following expressions: 2
.
(a) 5 // 10 * 9 % 3 ** 8 + 8 – 4
(b) 65 > 55 or not 8 < 5 and 0 != 55
Q22 Explain the use of ‘Foreign Key’ in a Relational Database Management System. 2
.
Give example to support your answer.
Q23 Expand the following terms: 2
. IMAP sHTTP URL POP3
Q24 Predict the output of the Python Code given below: 2
. d={"Rohan":67,"Ahasham":78,"naman":89,"pranav":79}
print(d)
sum=0
for i in d:
sum+=d[i]
print(sum)
print("sum of values of dictionaries",sum)
or
(i) def check(x,y):
if x != y:
return x+5
else:
return y+10
print(check(10,5))
Q25 Write the full forms of DDL and DML. Write any two commands of DDL in SQL. 2
. Or
In SQL, write the name of the aggregate function which is used to calculate &
display the sum of numeric values in an attribute of a relation.
Section- C
Q26 Write the outputs of the SQL queries (i) to (iii) based on the given tables: 3
.
Table: Event
EventID Event NumPerformers CelebrityID
101 Birthday 10 C102
102 Promotion Party 20 C103
103 Engagement 12 C102
104 Wedding 15 C104

Table: Celebrity
CelebrityID Event Phone FeeCharged
C101 FaizKhan 9910154555 200000
C102 Sanjay Kumar 6546454654 250000
C103 Neera Khan 4654656544 300000
C104 Reena Bhatia 9854664654 100000

(i) SELECT Event, NumPerformers FROM Event where EvenID>102;


(ii) SELECT max(FeeCharged), min(FeeCharged) FROM Celebrity;
(iii) SELECT Event.Event, Event.NumPerformers, Celebrity.Phone ,
Celebrity.FeeCharged FROM Event, Celebrity WHERE
Event.Celebrity = Celebrity.CelebrityID;

Q27 Write a function in Python that counts the number of “the” or “this” words 3
. present in a text file “myfile.txt”.
Example: If the “myfile.txt” contents are as follows:
This is my first class on Computer Science. File handling is the easiest topic for
me and Computer Networking is the most interesting one.
The output of the function should be: Count of the/this in file: 3

OR
Write a function countVowels() in Python, which should read each character of a
text file “myfile.txt”, count the number of vowels and display the count.
Example: If the “myfile.txt” contents are as follows:
This is my first class on Computer Science.
The output of the function should be: Count of vowels in file: 10
Q28 3

Q29 Write a function INDEX_LIST(L), where L is the list of elements passed 3


as argument to the function. The function returns sum of odd nos in list .

Q30 Two list Lname and Lage contains name of person and age of person 3
respectively. A list named Lnameage is empty. Write functions as details given
below
(i) Push_na() :- it will push the tuple containing pair of name and age
from Lname and Lage whose age is above 50
(ii) Pop_na() :- it will remove the last pair of name and age and also print
name and age of removed person. It should also print “underflow” if
there is nothing to remove
For example the two lists has following data
Lname=[‘narender’, ‘jaya’, ‘raju’, ‘ramesh’, ‘amit’, ‘Piyush’]
Lage=[45,23,59,34,51,43]

After Push_na() the contains of Lnameage stack is


[(‘raju’,59),(‘amit’,51)]
The output of first execution of pop_na() is
The name removed is amit
The age of person is 51
OR
A dictionary stu contains rollno and marks of students. Two empty list stack_roll
and stack_mark will be used as stack. Two function push_stu() and pop_stu() is
defined and perfom following operation
(a) Push_stu() :- It reads dictionary stu and add keys into stack_roll and
values into stack_marks for all students who secured more than 60
marks.
(b) Pop_stu() :- it removes last rollno and marks from both list and print
“underflow” if there is nothing to remove
For example
stu={1:56,2:45,3:78,4:65,5:35,6:90}

values of stack_roll and stack_mark after push_stu()


[3,4,6] and {78,65,90}
Section-D
Q31 Tech Up Corporation is a professional consultancy company. The company is
planning to set up their offices in India with it’s hub at Hyderabad. As a network
advisor, you have to understand their requirement and suggest to them the best
available solutions.
Block to Block distance (in meters):
Block (From) Block Distance (in meter)
Human Resource Conference 60
Human Resource Finance 60
Conference Finance 120
Expected number of Computers to be installed in each block:

Block Computer
Human Resource 125
Finance 25
Conference 60

(a) What will be the most appropriate block where TUC should plan to install 1
their server?
(b) What will be the best possible connectivity out of the following to 1
connect its new office in Bengaluru with its London based office?
(i) Infrared
(ii) Satellite Link
(iii) Ethernet Cable
(c) Which of the following devices will you suggest to connect each
1
computer in each of the above blocks?
(i) Gateway
(ii) Switch
(iii) Hub
(iv) Modem
1
(d) Write names of any two popular open Source software which are used as
Operating Systems.
1
(e) Suggest an ideal layout for connecting these blocks/centers for a wired
connectivity
Q32 (a) Write the output of the code given below: 2+3

p=5
def sum(q,r=2):global
p p=r+q**2
print(p, end=
'#')

a=10
b=5
sum(a,b)
sum(r=5,q=1)

(b) The given program is used to connect with MySQL abd show the name of the
all the record from the table “stmaster” from the database “oraclenk”. You are
required to complete the statements so that the code can be executed properly.
import .connector_as_pymysql

dbcon=pymysql. (host=”localhost”, user=”root”,


=”sia@1928”)
if dbcon.isconnected()==False:
print(“Error in establishing connection:”)
cur=dbcon. ()
query=”select * from stmaster”
cur.execute( )
resultset=cur.fetchmany(3)
for row in resultset:
print(row)
dbcon. ()
OR

(a) Predict the output of the code given

below: s="welcome2cs"
n = len(s)m=""
for i in range(0, n):
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 tablenamed
student and displays only those records who have marks greater than
75:
RollNo –
integer Name –
string Clas –
integer Marks –
integer

Note the following to establish connectivity between Python andMYSQL:


 Username is root
 Password is tiger
 The table exists in a MYSQL database named school.

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 75.
Statement 3- to read the complete result of the query (records whose
marks are greater than 75) into the object named data, from thetable
studentin the database.

import mysql.connector as mysqldef sql_data():

con1=mysql.connect(host="localhost",user="root",password="tiger",
database="school")
mycursor= #Statement 1
print("Students with marks greater than 75 are :")
#Statement 2
data= #Statement 3
for 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 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 mobileto store employee id, employeename and
employee salary respectively.
(ii) COUNTR() – To count the number of records present in the
CSVfile named ‘record.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:

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


‘furdata.csv’. Each record consists of a list with fieldelements as
fid, fname and fpriceto store furnitureid, furniture name and
furniture price respectively.
search()- To display the records of the furniture whoseprice is more than 10000.
Section-E
Q34 Nishant creates a table RESULT with a set of records to maintain the marks 1+1+
secured by students in Sem 1, Sem2, Sem3 and their division. After 2
creation of the table, he has entered data of 7 students in the table.
ROLL_NO SNAME SEM1 SEM2 SEM3 DIVISION
101 KARAN 366 410 402 I
102 NAMAN 300 350 325 I
103 ISHA 400 410 415 I
104 RENU 350 357 415 I
105 ARPIT 100 75 178 IV
106 SABINA 100 205 217 II
107 NEELAM 470 450 471 I

Based on the data given above answer the following questions:

(i) Identify the most appropriate column, which can be consideredas


Primary key.
(ii) If two columns are added and 2 rows are deleted from the
tableresult, what will be the new degree and cardinality of the above
table?
(iii) Write the statements to:
a. Insert the following record into the table
Roll No- 108, Name- Aadit, Sem1- 470, Sem2-444, Sem3-475,
Div – I.
b. Increase the SEM2 marks of the students by 3% whose
name begins with ‘N’.
OR (Option for part iii only)

(iii) Write the statements to:


a. Delete the record of students securing IV division.
b. Add a column REMARKS in the table with datatype
as varcharwith 50 characters
Q35 Anamika is a Python programmer. She has written a code and created a binary
file data.dat with sid, sname and marks. The file contains 10 records.
She now has to update a record based on the sid entered by the user and
update the marks. The updated record is then to be written in the file
extra.dat. The records which are not to be updated also have to be written to
the file extra.dat. If the sid is not found, an appropriate message should to be
displayed.
As a Python expert, help him to complete the following code based on
requirement given above:
import ……………. #Statement 1
def update_data():
rec={}
fin=open("data.dat","rb")
fout=open(" ") #Statement 2
found=False
eid=int(input("Enter student id to update their marks ::
")) while True:
try:
rec= #Statement 3
if rec["student id"]==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 student id ",sid," hasbeen updated.")
else:
print("No student with such id is not found")
fin.close()
fout.close()
1
(i) Which module should be imported in the program? (Statement1)
(ii) Write the correct statement required to open a temporary
1
filenamed extra.dat. (Statement 2)
(iii) Which statement should Anamika fill in Statement 3 to read the
data from the binary file, data.dat and in Statement 4 towrite the updated data 2
in the file, extra.dat?
SAMPLE PAPER SET 6

CLASS – XII SUBJECT: Computer Science-083

Total Time- 3 Hours Total Marks- 70

General Instructions:

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


2. All questions are compulsory.
3. Section A has 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
isgiven in Q35 against part c only.
8. All programming questions are to be answered using Python Language only.

Q1. State True or False 1


“variable declaration is implicit in Python”
Q2. Which type of Programming does Python support? 1
(a) object-oriented programming
(b) structured programming
(c) functional programming
(d) all of the mentioned
Q3 Which of the following is an invalid datatypes in Python? 1
(a) Set
(b) None
(c) Integer
(d) Real
Q4. Given the following dictionaries 1
exam={"Exam":"AISSCE","Year":2023}
result={"Total":500,"Pass_Marks":165}
(a) dict_exam.update(result)
(b) dict_exam+result
(c) dict_exam.add(result)
(d) dict.merge(result)
Q5. Suppose a tuple T is declare as: 1
T=(10,12,43,39)
Which of the following is in correct?
(a) print(t[1])
(b) T[2]=-29
(c) print(max(T)
(d) print(len(T))
Q6. What is the output of the following? 1
print('KV Sangathan'.split('an'))
(a) ['KV S', 'gath', ' ']
(b) [‘KV Sangathan’,’an’]
(c) [‘KV’,’Sang’,’athan’]
(d) All of them
Q7. What is the output of the following code. 1
Str1=”Hello World”
str1.replace('o','*')
str.replace('o','*')
(a) Hello World
(b) Hell* W*rld
(c) Hello W*rld
(d) Error
Q8. What is the datatype of the result set extracted from the databaseusing the cursor 1
object when we use the following:
(a) fetchone( ) method
(b) fetchall( ) method
Q9. Which of the following commands will be delete the table from MYSQL 1
Database?
(a) Delete table
(b) Drop Table
(c) Remove Table
(d) Alter Table

Q10 If the following code is executed, what will be the output of the following code? 1
. name="Kendriya Vidyalaya Sangathan"
print(name[2:13:2])
(a) Kendriya
(b) Vidyalaya
(c) Sangathan
(d) nry iy
Q11 Which of the following types of table constraints will prevent the printing of 1
.
duplicate values after the Select statement fetches data from table?
(a) Unique
(b) Distinct
(c) Primary Key
(d) NULL
Q12 The Correct syntax of seek() is: 1
.
(a) File_object.seek(offset[,reference_point])
(b) seek(offset[,referece_point])
(c) seek(offset,file_object)
(d) seek.file_object(offset)
Q13 (i) Expand the following: 1
. ARPANET, TCP/IP
Q14 What will the following expression be evaluated to in python? 1
. print(15.0/4+(8+3.0))
(a) 14.5
(b) 14.0
(c) 15
(d) 15.5
Q15 Which function is used to display the total number of records from table in a database? 1
. (a) sum(*)
(b) total(*)
(c) count(*)
(d) return(*)
Q16 To establish a connection between Python and sql database, connect() is used. Which of 1
. the following arguments may not necessarily be given while calling connect() ?
(a) host
(b) database
(c) user
(d) password

Q17 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
(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):-Serialization is the process of transforming data to a stream of bytes 1
Reasoning (R):-It is also known as Picking

Q18 Assertion (A): CSV (Comma Separated Values) is a file format for data storage which looks 1
. like a text file.
Reason (R): The information is organized with one record on each line and each
Section-B
Q19 Mr. Ram has written a code to input two numbers and swap the number using function 2
. but he has some error in his coding, so help him to rectify the errors and rewrite the
correct code.
Def swap(a,b)
c=a
a=b
b=c
print("a is",a,"b is",b )
#main()
a=int(input("enter in a "))
b=int(input("enter in b"))
Swap(a,b)#calling a function
Q20 What is the difference between a hub and a switch in context of computer networking 2
.
devices?
OR
Differentiate between HTTP and FTP.
Q21 Evaluate the following expressions: 2
.
(a) 5 // 10 * 9 % 3 ** 8 + 8 – 4
(b) 65 > 55 or not 8 < 5 and 0 != 55
Q22 Explain the use of ‘Foreign Key’ in a Relational Database Management System. Give 2
.
example to support your answer.
Q23 Define the following terms: 2
. Web server, Web Hosting
OR
Give two advantages and two disadvantages of bus topology.
Q24 Predict the output of the Python Code given below: 2
. d={"Rohan":67,"Ahasham":78,"naman":89,"pranav":79}
print(d)
sum=0
for i in d:
sum+=d[i]
print(sum)
print("sum of values of dictionaries",sum)
or
for i in range(1,3):
print('answer ',i,'is', i**2)
Q25 Write the full forms of DDL and DML. Write any two commands of DDL in SQL. 2
. Or
Categories the following commands as DDL or DML:
INSERT, UPDATE,ALTER,DROP

Section- C
Q26 Write the outputs of the SQL queries (i) to (iii) based on the given tables: 3
.
Table: Event
EventID Event NumPerformers CelebrityID
101 Birthday 10 C102
102 Promotion Party 20 C103
103 Engagement 12 C102
104 Wedding 15 C104

Table: Celebrity
CelebrityID Event Phone FeeCharged
C101 FaizKhan 9910154555 200000
C102 Sanjay Kumar 6546454654 250000
C103 Neera Khan 4654656544 300000
C104 Reena Bhatia 9854664654 100000

(i) SELECT Event, NumPerformers FROM Event where EvenID>=104;


(ii) SELECT max(FeeCharged) FROM Celebrity;
(iii) SELECT Event.Event, Event.NumPerformers, Celebrity.Phone ,
Celebrity.FeeCharged FROM Event, Celebrity WHERE Event.Celebrity =
Celebrity.CelebrityID;

Q27 Write a user-defined function named count() that will read the 3
. contents of text file named “Story.txt” and count the number
of lines which starts with either “I‟ or “M‟. E.g. In the following
paragraph, there are 2 lines starting with “I‟ or “M‟:
OR
Write a function countmy( )in Python to read the text file “Story.txt” and
count the number of times “my” or “My” occurs in the file. For example if
the file “Story.TXT” contains:
“This is my website. I have displayed my preferences in the CHOICE
section.”
The countmy( ) function should display the output as: “my occurs 2 times”.

Q28 (a) Write the output of the following sql queries (i) to (iv) based on the relations 3
Teacher and Placement given below:
Table: Teacher

T_ID Name Age Department DOJ Salary Gender


1 Arunan 34 Computer Sc 2019-01-01 12000 M
2 Saman 31 History 2017-03-24 20000 F
3 Randeep 32 Mathematics 2020-12-12 30000 M
4 Samira 35 History 2018-07-01 40000 F
5 Raman 42 Mathematics 2021-09-05 25000 M
6 Shyam 50 History 2019-06-27 30000 M
7 Shiv 44 Computer Sc 2019-02-25 21000 M
8 Shalakha 33 Mathematics 2018-07-31 20000 F

Table :Placement
P_ID Department Place
1 History Ahmedabad
2 Mathematics Jaipur
3 Computer Sc Nagpur

(i) SELECT Department, avg(salary) FROM Teacher GROUPBY Department;


(ii) SELECT MAX(DOJ), MIN(DOJ ) FROM Teacher;
(iii) SELECT NAME , SALARY, T. Department, Place from Teacher T, Placement P where
T. Department =P.Department and Salary>20000;
(iv) SELECT Name, Place from Teacher T, Placement P;
Q29 Write a program to calculate and display the sum of all the odd numbers in the list. 3
Q30 Alam has a list containing 10 integers. You need to help him create a program with 3
separate user
defined functions to perform the following operations based on this list.
l Traverse the content of the list and push the even numbers into a stack.
l 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
Write a function in Python, Pop(Arr), where Arr is a stack implemented by a list of
numbers. The function should return the value deleted from the stack.
Section-D
Q31 National Centre for Indigenous Arts has just set up a new Campusand they want to
set up a Local area network.

The distances between various buildings of university aregiven as:-


Main to Admin 50 mtr Main to
Finance 100 mtrMain to
Academic 70 mtr Admin to
Finance 50 mtr Finance
to Academic70 mtrAdmin to Academic
60 mtr
Number of computers in each
building:- Main Building 150
Admin Building 75
Finance Building 50
Academic Building 60

As a network expert, you are required to give best possiblesolutions for the given
queries of the university administration:-
1

(a) Suggest and draw cable layout to efficiently connect various


buildings/blocks. 1

(b) Suggest the most suitable building to house the server of this university
with a suitable reason.

(c) Suggest the placement of following devices with justification:


1. Switch/Hub 1
2. Repeater
(d) Suggest the transmission medium out of the following for setting-up very 1
fast Internet connectivity among buildings of the university
1. Optical Fiber 1
2. Coaxial cable
3. Ethernet Cable

Q32 (a) Write the output of the code given below: 2+3

p=5
def sum(q,r=2):global p
p=r+q**2
print(p, end= '#')

a=10
b=5 sum(a,b)
sum(r=5,q=1)

(b) The code given below inserts the following record in the tableStudent:
RollNo – integer
Name – string
Class– integer
Marks – integer

Note the following to establish connectivity between Python andMYSQL:


Username is root,Password is tigerThe table exists in a MYSQL database named
school.The details (RollNo, Name, Clas and Marks) are tobe 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 thetable Student.
Statement 3- to add the record permanently in the database

import mysql.connector as mysql

def sql_data():
con1=mysql.connect(host="localhost",user="root",password="tiger",database="s
chool")
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="hello kv *& INDia"


n = len(s)
m=""
for i in range(0, n):
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 tablenamed student
and displays only those records who have marks greater than 75:
RollNo – integer
Name – string
Clas – integer
Marks – integer

Note the following to establish connectivity between Python andMYSQL:


 Username is root
 Password is tiger
 The table exists in a MYSQL database named school.

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 thosestudents whose
marks are greater than 75.
Statement 3- to read the complete result of the query (records whose
marks are greater than 75) into the object named data, from thetable studentin
the database.

import mysql.connector as mysql


def sql_data():

con1=mysql.connect(host="localhost",user="root",password="tiger",
database=" ") statement 1
mycursor= #Statement 2
print("Students with roll greater than 10 are :")
data= #Statement 3
for 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 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 mobileto
store employee id, employeename and employee salary respectively.
(ii) COUNTR() – To count the number of records present in the CSVfile
named ‘record.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:

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


‘furdata.csv’. Each record consists of a list with fieldelements as fid,
fname and fpriceto store furnitureid, furniture name and furniture
price respectively.
search()- To display the records of the furniture whoseprice is more than 10000.
Section-E
Q34 Nishant creates a table RESULT with a set of records to maintain the marks secured 1+1+
by students in Sem 1, Sem2, Sem3 and their division. After creation of the table, he 2
has entered data of 7 students in the table.
ROLL_NO SNAME SEM1 SEM2 SEM3 DIVISION
101 KARAN 366 410 402 I
102 NAMAN 300 350 325 I
103 ISHA 400 410 415 I
104 RENU 350 357 415 I
105 ARPIT 100 75 178 IV
106 SABINA 100 205 217 II
107 NEELAM 470 450 471 I

Based on the data given above answer the following questions:

(i) Identify the most appropriate column, which can be consideredas Primary
key.
(ii) If 3 columns are added and 2 rows are deleted from the tableresult, what
will be the new degree and cardinality of the above table?
(iii) Write the statements to:
a. Insert the following record into the table
Roll No- 110, Name- Aadit, Sem1- 470, Sem2-444, Sem3-475, Div – I.
b. Increase the SEM2 marks of the students by 3%
whosename begins with ‘N’.

OR (Option for part iii only)

(iii) Write the statements to:


a. Delete the record of students securing I division.
b. Add a column REMARKS in the table with datatype
as varcharwith 100 characters
Q35 Devi is a Python programmer. He has written a code and created a binary file record.dat
with employeeid, ename and salary. The filecontains 10 records.
He now has to update a record based on the employee id entered bythe user and
update the salary. The updated record is then to be written in the file temp.dat. The
records which are not to be updated also have to be written to the file temp.dat. If
the employee id is not found, an appropriate message should to be displayed.
As a Python expert, help him to complete the following code based onthe requirement
given above:

import #Statement 1
def update_data():
rec={}
fin=open("record.dat","rb")
fout=open(" -------“) ") #Statement 2
found=False
eid=int(input("Enter employee id to update theirsalary ::
")) while True:
try:
rec= #Statement 3
if rec["Employee id"]==eid:
found=True
rec["Salary"]=int(input("Enter new salary:: "))
pickle. #Statement 4
else:
pickle.dump(rec,fout)except:
break
if found==True:
print("The salary of employee id ",eid," hasbeen updated.")
else:
print("No employee with such id is not found")fin.close()
fout.close()

(i) Which module should be imported in the program? (Statement1)


(ii) Write the correct statement required to open a temporary 1
filenamed temp.dat. (Statement 2)
(iii) Which statement should Aman fill in Statement 3 to read the 1
data from the binary file, record.dat and in Statement 4 towrite the updated data in the
file, temp.dat? 2

You might also like