4th 5th and 6th Paper
4th 5th and 6th Paper
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
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
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?
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.
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:
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
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.
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
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:
import mysql.connector as
SECTION E
8
34 Nawal Rao creates a table Emp 1+1+2
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
General Instructions:
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
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
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]
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
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
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:
General Instructions:
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
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
Table :Placement
P_ID Department Place
1 History Ahmedabad
2 Mathematics Jaipur
3 Computer Sc Nagpur
As a network expert, you are required to give best possiblesolutions for the given
queries of the university administration:-
1
(b) Suggest the most suitable building to house the server of this university
with a suitable reason.
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
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
(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
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) 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’.
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()