0% found this document useful (0 votes)
30 views

Solvedanswer

Answer key
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views

Solvedanswer

Answer key
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 73

Sample Set-1

1 Comma Seperated Values


2 d if
3 a) 5Total
4 b) 51 51+4-1-3=51
5 c uteruter
6 a) csv
7 b) update
8 d Select
9 c) Statement-3
10 ii)NOT NULL
11 a) file_object.read()
12 c) show databases
13 a)SMTP
14 159
15 a) MAX
16 b)connect()
17 a) Both A and R are true and R is the correct explanation for A
18 d)A is False but R is True
19
def execmain():
---------------------
x =int( input("Enter a number:"))
--------------------------------------
if (abs(x)==x):
------------------
print ("You entered a positive number")
else:
x*=-1
---------
print( "Number made positive:",x)
---------------------------------------------
execmain()
20 Star topology -Centralised Control ,Easy to detect and isolate faulty computers
Bus topology-Linear Architecture;Simple and easy to extend
or
Hypertext Markup Language is used to design webpages
Hypertext Transfer Protocol is used to transfer webpages across Internet

21a) nuaa l
b)400 420

22 Data Definition Language commands affect structure


of a table and Data Manipulation Language commands
affect records of a table
DDL -ALTER,DROP,Create DML-Insert,update,select,delete

23 a)
i) Uniform Resource Locator
ii) File Transfer Protocol

24 2 4
64

or
2,2,0,1,2

24 a) mysql.connector
b) execute queries
row by row processing of records using fetchall(),fetchone(),fetchmany()
count the number of records
or
A field used to uniquely identify records from the table

student
Roll Name
1 Raj
2 Anil

Roll is the primary key

Q26
TID TNAME CITY HIREDATE SALARY CID CNAME FEES STARTDATE
101 Sunaina Mumbai 1998-10-15 90000 C201 AGDCA 12000 2018-07-02
101 Sunaina Mumbai 1998-10-15 90000 C205 DHN 20000 2018-08-01
102 ANAMIKADelhi 1994-12-24 80000 C203 DCA 10000 2018-10-01
103 Deepthu Chandigarg 2001-12-21 82000 C202 ADCA 15000 2018-07-15
104 Meenakshi Delhi 2002-12-25 78000 C204 DDTP 9000 2018-09--15
105 Richa Mumbai 1996-01012 95000 C206 O level 18000 201-07-25

b
city
Mumbai
Chandigarg

TID, COUNT(*) MAX(FEES)


101 2 20000

TNAME CNAME
Meenakshi DDTP

COUNT(CITY),CITY
2 Mumbai
2 Delhi
1 Chandigarg
1 Chennai

27

def COUNTLINES_ET():
E=T=0
f=open("Report.txt","r")
L=f.readlines()
for l in L:
if l[0]=='E':
E+=1
if l[0]=='T':
T+=1
print("No. of Lines with E:",E)
print("No. of Lines with T:",T)

or
def SHOW_TODO():
f=open("ABC.txt","r")
L=f.readlines()
for l in L:
for y in l.split():
if y=='TO' or y=='DO':
print(l)
28
Department, count(*)
Computer Sc 2
History 3
Mathematics 3

Max(Date_of_Join) Min(Date_of_Join)
31/07/2018 05/09/2007
name Department Place
Jugal Computer Sc Delhi
Shiv Om Computer Sc Delhi

Gender, COUNT(Gender)
M 5
F 3

Describe Teacher;

29
def oddeve(L):
T=[]
for x in L:
if x>0:
T.append(x)
print(T)

30
Cstack=[]
def AddCustomer(Customer):
Cstack.append(Customer)
print(Cstack)
or
def DeleteCustomer():
while True:
if Cstack==[]:
break
else:
print(Cstack.pop())

31
a)Admin

b) Admin
/ | \
Management Medicine Law

c)Switch
d)Ethernet Cable
e)LAN

32 6
a)cCICKEe
b)
mysql.connector
execute()
mysql.connector.connect (host='192.168.11.111',user='root',password='Admin',Database='MYPROJECT')

33
a)G*L*TME
b) mysql.connector
cursor()
execute(query)

33.Pickle module is used to convert any object into bytes ie serialisation or


pickling done with the help of dump()
pickle.dump(object,file_object)

It can perform deserialisation or unpickling to convert bytes


to the originalobject done with the help of load()
object=pickle.load(file_object)
import csv
f=open('one.csv','w',newline=‘ ')
writer=csv.writer(f)
writer.writerow(['Roll.No', 'Name', 'Marks'])
while True:
rollno = int(input("Enter Roll No"))
name = input("Enter Name")
marks = int(input("Enter Marks"))
L = [rollno,name,marks]
writer.writerow(L)
ch=input("Continue y/n")
if ch in 'Nn':
break;
f.close()

orAns.tell(): It returns the current position of cursor in file.


====
The tell() function takes no parameter.
Example:
fout=open(“story.txt”,”w”)
fout.write(“Welcome Python”)
print(fout.tell( ))
fout.close( )
14
seek()
=====
Change the cursor position by bytes as specified by the offset.
Can have 1 or maximum 2 parameters
Syntax
file_object.seek(offset ) #absolute positioning from begining 0
file_object.seek(offset [, reference_point]) #relative positioning
reference_point can be
0 – Default. Sets the point of reference at the beginning of the file.
1 – Sets the point of reference at the current position of the file.
2 – Sets the point of reference at the end of the file.
Eg
fout=open(“story.txt”,”w”)
fout.write(“Welcome Python”)
fout.seek(5)
print(fout.tell( ))
fout.close( )
5
import csv
f=open("student.csv","r")
reader=csv.reader(f)
next(reader)
print("Students Scored More than 80")
for x in reader:
if int(x[2])>80:
print("Roll Number =", x[0])
print("Name =", x[1])
print("Marks=", x[2])
f.close( )

34
a)Degree 5 Cardinality 6
b)TID has no duplicate values and has no NULL values .
So it is a primary key
c)
i)Insert into Trainer values(107,"Bhoomi","Delhi","2001-12-15",90000);
ii)Update Trainer set salary=salary+0.01*salary where salary>80000;
or

i)Delete from Trainer where TName='Richa';


ii)Alter table Trainer add Remarks varchar(50);
35
csv
'r'
Line-2 'emp.csv','r'
Line-3 reader

Sample Set-2
1 True
2 c ans
3 d) {1: “One”,2: “Two”, 3: “C”,4: ‘Four’,5: ‘Five’}
4 c) 0
5b) [‘I’, ‘N’, ‘F’, ‘O’, ‘R’, ‘M’, ‘A’, ‘T’, ‘I’, ‘C’, ‘S’]
6 a)
7 b) alter
8 c) ORDER BY
9d) statement 4
10 foreign key
11c) both iii and iv
12 b) Constraint
13 d) Router
14
18 / 16//5-8
0.0-8
-8.0
=====
15d) Cartesian Product
16 b) Username, Password, Hostname
17 (c) A is True but R is False
18 (b) Both A and R are true and R is not the correct explanation for A

19
def sumdigits(n):
d=0
for x in str(n):
d=d+int(x)
--------------
return d
---------
n=int(input("Enter any number”))
------
s=sumdigits(n)
print(“Sum of digits”,s)

20
Switch To connect all computers within a building
or between LANs
Switch filters data packets

Router Connects networks using similar protocols


Routes internet taffic and packets can travel through
different paths
or
Web Server accepts requests from Browser
Process and return response as HTML
It is a software that resides in server machine
Eg Google web server
Web Browser sends requests to Server
Converts received HTML to webpage and
displays it
Eg Google Chrome

21
a) [10,30,50,70]
b) 16

22 Primary key is used to uniquely identify records from the table

student
Roll Name Marks
1 Raj 99
2 Anil 99
3 Raj 77

Here Roll has no NULL values and duplicate values

23 Post Office Protocol Version 3


Transmission Control Protocol/Internet Protocol

24 [5,11,12] [5,11,12]
(9, 10, 5, 6, 7)
25
char varchar
fixed length varying length
spaces padded no spaces padded
wastage of memory no wastage of memory
gender char(5) gender varchar(5)

F---- F

types of aggregate functions are min(),max(),sum()


max()-to return maximum value in a column
count(*) -to return number of functions
Roll Name Marks
1 Raj 99
2 Anil 99
3 Raj 77
max(Marks) 99
count(*) 3

26a)UCODE UNAME UCOLOR UCODE SIZE PRICE


1 Shirt White 1 L 580
1 Shirt White 1 M 600
2 Pant Grey 2 L 800
2 Pant Grey 2 M 810
b)PName, Average (UPrice)
Washing Powder 120
Toothpaste 59.5
Soap 31.5
Shampoo 245

Manufacturer
Surf
Colgate
Lux
Pepsodent
Dove

COUNT (DISTINCT PName)


4
PName MAX(UPrice) MIN(UPrice)
Washing Powder 120 120
Toothpaste 65 54
Soap 38 25
Shampoo 245 245

27
def countwords():
f=open('myfile.txt',''r")
w=f.read().split()
c=0
for x in w
for y in x:
if y.isdigit():
c+=1
break
print("Count=",c)
or
def countwords():
f=open('myfile.txt',''r")
w=f.read().split()
my=me=0
for x in w:
if x=='me':
me+=1
elif x==my:
my+=1
print("Count of me=",me)
print("Count of my=",my)

28COUNT(*) CITY
3 Delhi
2 Mumbai

MIN(PRICE), MAX(PRICE)
50000 70000

PRODUCTNAME CITY PRICE


MOBILE MUMBAI 70000
MOBILE MUMBAI 25000

NAME CITY PRICE


Rohan Mumbai 70000
Deepak Delhi 50000
Mohan Delhi 30000
Sahil Delhi 35000
Arun Delhi 50000

b) show tables;

29
def listchange(Arr,n): #List is mutable
for i in range(n):
if Arr[i]%2==0:
Arr[i]*=2
else:
Arr[i]*=3

30)
status=[]
def Push_element():

Rno=int(input("Enter roll:"))
Name=input("Enter name")
Dob=input("Enter Date")
Class=input("Enter class")
student=[Rno, Name, Dob, Class]
status.append(student)
def Pop_element():
while status!=[]:
print(status.pop())
print("Empty")

or
status=[]
def Push(Book):
count=0
for k,v in Dbook.items():
if v>300:
status.append(k)
count=count+1
print("The count of elements in the stack is : ", count)

31
(a) Research building - Academic building - Admin building

(b) The most suitable place to house the server is Academic Building as it has maximum number of
computers. Thus, it decreases the cabling cost and keeps the maximum traffic local.

(c) Switch can be installed in each of building to connect all the computers.

(d) Repeater not needed as per layout as the distance does not exceed 100m

(e) Satellite connection is the most suitable service to provide data connectivity between Admission Building
located in Delhi and the campus located in Parampur.

32
a)
50#5
b)mydb.cursor()
({},'{}','{}',{})
execute(rq,rtup)
or
fUNnpYTHON
mydb.cursor()
execute("Select * from Employee where salary betweeen 30000 and 90000")
mycursor.fetchall()

33
tell() toreturn the current position of file pointer
f=open("poem.txt","r")
f.seek(5)
print(f.tell())

5
import csv
def ADD():
f=open("record.csv","a",newline="")
while True:
w=csv.writer(f)
admno=int(input("Enter no "))
sname=input("Enter name ")
class=input("Enter class ")
l=[admno,sname,class]
w.writerow(l)
ch=input("Add y/n")
if ch in 'Nn':
break
f.close()
def COUNT():
f=open("record.csv","r")
r=csv.reader(f)
c=0
for x in r:
if x[2]=="12":
c+=1
print("Count=",c)
f.close()
ADD()
COUNT()

or
Pickle module is used to convert any object into bytes ie serialisation or
pickling done with the help of dump()
pickle.dump(object,file_object)

It can perform deserialisation or unpickling to convert bytes


to the originalobject done with the help of load()
object=pickle.load(file_object)

import csv
def ADD():
f=open("animal.csv","a",newline="")
while True:
w=csv.writer(f)
name=input("Enter name ")
type=input("Enter type ")
food=input("Enter food ")
l=[name,type,food]
w.writerow(l)
ch=input("Add y/n")
if ch in 'Nn':
break
f.close()
def SEARCH():
f=open("animal.csv","r")
r=csv.reader(f)
for x in r:
if x[2]=="grass":
print(x[0],x[1])

f.close()
ADD()
SEARCH()

34
a) EMPNO
b)degree=6
cardinality=9

c)
i)Insert into Employee(empid,empname,empDept)
values(1042,'Abhinav','support')
ii)Describe employeel

or
c)
1)Alter table Employee add bonus float;
ii)Update employee
set bonus=0.2*salary;

35i) pickle
ii) "student.dat","rb"
iii) pickle.load(f)
rec[0]

Sample paper set 3


1 c) 2nd_num
2a) //
3b) Tuple
4a) 4.0+float(6)
5b) [ ]
6b) infile = open(“c:\\temp.txt”, “r”)
7a) insert into
8c) alter
9c) 30 12
10a) MAX()
11a) dt = f.readlines()
print(dt[3])
12c) Ascending
13b) Gateway
14b) 27.2
15d) ID
16a) fetchall
17Both A and R are true and R is the correct explanation for A
18Both A and R are true and R is not the correct explanation for A

19
num=int(input("Enter any integer number"))
fact=1
for x in range(num,1,-1):
---------------------------------
if num==1 or num==0:
---------------------------------
print ("Fact=1")
break
else:
--------
fact=fact*x
print(fact)

20 Wide Area Network


Satellite

or
Optical Fiber Ethernet Cable

Use light Uses electrical signal


High bandwidth Low Bandwidth
Very Fast Slow
Use fibres Use copper wire
Very security Less secure as it can be easily tapped

21
a)[[20,30,40]] b) (30,20) # [-1:-5:-2]
22 To uniquely identify a record in a table
Roll Name
1 Anil
2 Anil

Roll is primary key

23
a) Service _VideoConferencing and
Protocol is Voice Over Internet Protocol

b)File Transfer Protocol


Hypertext Transfer Protocol

24
12.0
35.0
24.0
16.0

or
15

25 To arrange records in asending or descending order


To filter records
Select * from student where age=16;
or
Degree is no:of colums
Cardinality is number of rows

26
.firstname salary
Rachel 32000
Peter 28000

count(distinct designation)
4

designation, sum(salary)
Manager 215000

sum(benefits)
6500

b) Equijoin joins tables based equality of values


in identical columns.The resultant table will have duplicate columns

Student Teacher
Sno Sname TID TID Tname
1 Anil T1 T1 Ravi
2 Raj T1 T2 Rekha

Equijoined table
Sno Sname TID TID Tname
1 Anil T1 T1 Ravi
2 Raj T1 T1 Ravi

27
def ReadMe():
f=open("data.txt","r")
c=0
s=f.read().split()
for w in s:
if w=='India':
c=c+1
print("Total count of India=",c)
or
def linecount():
f=open("data.txt","r")
c=0
L=f.readlines()
for x in L:
if x[0]=='P':
c=c+1
print("Line count=",c)

28 Select *from Transport


where capacity>Noofstudents order by rtno;

Select area_covered from Transport


where distance>20 and charges<80000;

sum(distance)
-----------------
50
min(noofstudents)
-----------------------
40

29 def AddOddEven(Values):
os=es=0
for x in Values:
if x%2==0:
es+=x
else:
os+=x
print("Even sum=",es)
print("Odd sum=",os)
30
Book_title=[]
def Pushon(Book):
Book_title.append(Book)
def Pop(Book):
if Book_title==[]:
print("Underflow")
else:
Book=Book_tile.pop()
print(Book)
or

def pop(student):
if student==[]:
print("Empty")
else:
print(student.pop())
def display(student):
if student==[]:
print("Empty")
else:
for i in range(-1,-len(student)-1,-1):
print(student[i][0],student[i][1])

n=int(input("Enter no : of students"))
student=[]
for i in range(n):
no=int(input("Enter number"))
name=input("Enter name")
student.append([no,name])
print("1.Pop")
print("2.Display")
while True:
ch=int(input("Enter choice"))
if ch==1:
pop(student)
elif ch==2:
display(student)
else:
break
31 Administrative Office
AO
/ | \
OU PU NU
Switch

Bus Topology Ethernet Cable


Firewall

32 first 2,3,4,5,6,7
second 2,3,4,5,6,7
third 3,4,5,6,7,8

a) i) correct
ii) con1.cursor()
mycursor.execute(querry)
con1.commit()

or
a)PYTHON#0#0
b)import mysql.connector as conn
conn = db.connect(host=”localhost”, user=‘root’, password =‘ ’, database=”Society”)
cursor = conn.cursor()
cursor.execute('SELECT COUNT(MemberID) as count FROM Members WHERE id = 1')
row = cursor.fetchone()
conn.close()
print(row)
33
1. csv
2. "Student.csv","w"
3. writer(fh)
4. roll_no,name,Class,section
5. writerows()

or
i. r
ii. file.read()
iii line.split()
iv. len(c)<4
v.. file.close()
34
Delete from worker;

WORKER_ID

Alter table worker


modify first_name varchar(20);

Describe worker;

or
Create table worker(WORKER_ID char(3),
FIRST_NAME varchar(10),
LAST_NAME varchar(10),
SALARY float,
JOINING_DATE DATE);
35
import pickle
def AddStudents():
f=open('student.dat','wb')
while True:
Rno = int(input("Rno :"))
Name = input("Name : ")
Percent = float(input("Percent :"))
L = [Rno, Name, Percent]
pickle.dump(L,f)
Ch = input("enter more (y/n): ")
if Ch in "nN":
break
f.close()

def GetStudents():
Count=0
with open("STUDENT.DAT","rb") as F:
try:
while True:
R=pickle.load(f)
if R[2] > 75:
print(R[1], " has percent = ",R[2])
Count+=1
except:
pass
if Count==0:
print("There is no student who has percentage more than 75")
AddStudents()
GetStudents()

Sample Set 4

1c) 2ndName
2(b) List
3c. D1[“REMARK”] = “EXCELLENT”
4 not
and
or
T or F and T
T or F
(a) True

5.c) KENDRIYA#VIDYALAYA# REGION


6(b) file.readlines()
7(c) alter
8(c) Row
9b) Statement 4
10a) Primary Key
11b) load(), pickle
12b) DISTINCT
13(d) Both A and B
14 Ans 26.75

18.75+8
4 75
72
30
15smallest c) Min()
16b) connect()
17 (a) Both A and R are true and R is the correct explanation for A
18 (b) Both A and R are true and R is not the correct explanation for A

19
def DigitSum():
n = int( input("Enter number :: "))
-------------------------------------------
dsum = 0
while n > 0:
------------
d = n % 10
--------------
dsum =dsum + d
n = n //10
return dsum
---------
20 Electronic mail send across Internet
Advantages
1Faster
2.Can be forwarded to multiple recipients
or
Bus Star
=======================
No central node Central node is present
Difficult to detect Easy to diagnose and isolate
and isolate faulty computers
faulty computers

21 a Cntyo
b)Item @ Laptop
Make @ Dell
Price @ 57000

22 All those fields which have the chaces of becoming a primary key
are candidate keys
After selecting the primary key from the set of candidate keys
remaining candidate keys are alternate keys
23a) i) CODE DIVISION MULTIPLE ACCESS
ii)Voice Over Internet Protocol

B)Software that resides in client machice to display webpages


It sends request to server
Internet Explorer Google Chrome

24
[11,22,33,45,55,66]
[22,11,66,90,110,33]
or
(12,33,66)

25where having
applied before group by applied after group by

cannot work with can work with


aggregate functions aggregate functions

select dept,count(*) from emp where gender='F'


group by dept having count(*)>=2;
or
DDL-create table,alter table DML-insert,update

26 1.ItemNo
2.Insert into Items values (2010,'NoteBook',25,50);
3.Select *from Itemswhere ItemName like 'G%';

27
def display():
f=open("India.txt","r")
s=f.read()
w=s.split()
for x in w:
if len(x)==3:
print(x)

28 Count(*) Max(Price) book_name, author_name


5 750 Thunderbolts Anna Roberts
The Tears WilliamHopkins
book_id book_name quantity_issued
C001 Fast Cook 5
F001 The Tears 2
T001 My First C++ 4

29 def Reverse(X):
X.reverse()
for i in range(0,len(X)):
X[i]=X[i]*2

30
import pickle
def Readfile():
f=open("Employee.dat","rb");c=0
try:
while True:
L=pickle.load(f)
if 20000<= L[2]<=40000:
print(L[0],L[1])
c=c+1
except EOFError:
pass
f.close()

or
def DisplayAvgMarks(Sub):
f=open("Test.dat","rb");sum=0
c=0
try:
while True:
L=pickle.load(f)
if L[1]==Sub:
sum=sum+L[3]
c=c+1
except EOFError:
pass
print("Average=",sum/c)

31
Block C has maximum no: of computers
B
|
C-A
/
D
Switch
No repeater needed as distance is below 100m

Optical fiber

32 a) KVS*JAMMU
b)mysql.connector
mycursor.execute(querry)
con1.commit()

or

a) #Ack##AsIc
b) con1.cursor()
mycursor.execute("Select * from student where marks>85")
mycursor.fetchall()

33
a) Comma seperate value files
are delimited text files
in tabular format
It consist of rows
and columns where each column is seperated
by a delimiter(comma by default)
and ech row is seperated by '\r\n' by default

import pickle
f=open("Book.dat","wb")
def CreateFile():
while True:
bn=int(input("Enter no"))
name=input("Enter name")
aut=input("Enter author")
pr=float(input("Enter price"))
L=[bn,name,aut,pr]
pickle.dump(L,f)
ch=input("Add more y/n")
if ch in 'Nn':
break
f.close()

def CountRec(Author):
f=open("Book.dat","rb")
c=0
try:
while True:
L=pickle.load(f)
if L[2]==Author:
c=c+1
except EOFError:
pass
return c

or
a)
Binary CSV

pickle module csv module

Block by block data Data is stored as tabular format


processing

Machine friendly User friendly

Binary format Unicode Format

No delimiters Delimiter needed and carriage translation occurs


and no carriage By defaultdelimiter is comma
translation
Faster slower

def pushme (stock, item):


stock.append(item)

def popme(stock ):
if stock==[]:
print("Empty")
else:
print(stock.pop())

34 Empno
degree-8
cardinality-5
a) Insert into emp values
(8,'Ravi','Sales','Mgr','M',34000,'Delhi');

b) Update Emp set salary =salary +0.03*salary


where dept='Acct';

or
a Delete from Emp where city='Delhi';
b ALter table Emp
add Mobno varchar(10)

35 pickle
wb
pickle.dump
close()
Sample Set -5
1.(d) all of them
2(a) object-oriented programming
3(b) def
4{"Exam":"PB","Year":2013}
5 (a) True
6(a) ['KV S', 'gath', ' ']
7(b) wb
8(c) Drop
9(b) Drop Table
10(b) idyalaya
11(b) Distinct
12To return the current position of file pointer
13B. Unicast device
14 3.75 +24.0 (c) 27.7
15(a) sum(*)
16 to establish a unique session between Python and database
17(c) A is True but R is False
18(a) Both A and R are true and R is the correct explanation for
19
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
----------
20 Hub shared bandwith,broadcasts to all devices
and traffic congestion occurs and is slow
Switch dedicate bandwith,filters data
and no traffic congestion occurs and is faster
or
Hypertext Transfer Protocol for transferring webpages across Internet
File Transfer Protocol to upload and download files to/from a remote server

21
5 // 10 * 9 % 3 ** 8 + 8 – 4
5//10*9%6561+8-4
4
=
(b) 65 > 55 or not 8 < 5 and 0 != 55

T or not F and T
T or T and T
T or T
T
22 A filed in a table which may act as a primary key of another table
and is used for referential integrity
Student Score
No Name No SCode Marks
1 Anil 1 S1 100
2 Raj 1 S2 99
2 S1 88
2 S2 77
Score.No is the foreign key

23 Internet Mail Access Protocol


Hypertext Transfer Protocol Secure
Uniform Resource Locator
Post Office Protocol Version 3

24{"Rohan":67,"Ahasham":78,"naman":89,"pranav":79}
67
145
234
313
sum of values of dictionaries 313

or
15

25 Data Definition Language Create Alter


Data Manipulation Language Select Update
sum()

26 i)Event NumPerformers
Engagement 12
Wedding 15

ii) max(FeeCharged) min(FeeCharged)


300000 100000

iii)Event NumPerformers Phone FeeCharged


Birthday 10 6546454654 250000
Promotion Party 20 4654656544 300000
Engagement 12 6546454654 250000
Wedding 15 9854664654 100000

27
def COUNT_WORDS():
f=open("myfile.txt','r')
s=f.read().split()
c=0
for w in s:
if w in ['this','the']:
c=c+1
print("Count of the/this=",c)
or
def COUNT_VOWELS():
f=open("myfile.txt','r')
s=f.read()
c=0
for x in s:
if x.upper() in "AEIOU":
c=c+1
print("Count of vowels=",c)

28 Count(Publisher)
5
Max(Price)
650
Count(distinct Publisher)
3
29
def INDEX_LIST(L):
os=0
for x in List:
os+=x:
print("Odd sum=",os)

30

Lnameage=[];
def PUSH_na(Lname,Lage):
for i in range(len(Lname)):
if Lage[i]>50:
Lnameage.append( (Lname[i],Lage[i]))
def Pop_na():
if Lnameage==[]:
print("Underflow")
else:
t=Lnameage.pop()
print("The name removed is",t[0])
print("The age of person is",t[1])
Or
stack_roll=[];stack_mark=[]
def push_stu(D):
for k,v in D.items():
if v>60:
stack_roll.apppend(k)
stack_mark.append(v)

dep Pop_Stu:
if stack_roll==[] or stack_mark==[]:
print("Underflow")
else:
print("Roll",stack_roll.pop())
print("Marks",stack_mark.pop())
31
a) Human Resource
b)(ii) Satellite Link
c)(ii) Switch
d) GNULinux,FreeBSD
e)
HR
\
Finance
/
Conference

Q32A)105#6#
======

q 10 r 5 p=5+100=105
r5 q1 p=5+1=6

B) mysql
connect
password
cursor()
query
close()
or

sELCcME&Cc

b)con1.cursor()
mycursor.execute("Select *
from student where marks>75")
mycursor.fetchall()

33

CSV stores data as delimited text files in tabular format


Easy to create and generate and handle large volumes of data

B)
import csv;f=open("record.csv","w",newline='');writer=csv.writer(f)
def ADD():
while True:
id=int(input("Enter id"))
n=input("Enter name")
p=float(input("Enter mobile"))
L=[id,n,p]
writer.writerow(L)
ch=input("Add more y/n")
if ch in 'Nn':
break
f.close()

def CountR():
f=open("record.csv","r");reader=csv.reader(f)
c=0
for x in reader:
c+=1
f.close()
print("Total count=",c)

or
Binary CSV
pickle module csv module

process stores data in tabular


as blocks of data format

No delimiter Delimiter is comma by default

Faster Slower

import csv;f=open("furniture.csv","w",newline='');writer=csv.writer(f)
def ADD():
while True:
id=int(input("Enter id"))
n=input("Enter name")
p=float(input("Enter price"))
L=[id,n,p]
writer.writerow(L)
ch=input("Add more y/n")
if ch in 'Nn':
break
f.close()

def search():
f=open("record.csv","r");reader=csv.reader(f)
c=0
for x in reader:
if float(x[2])>10000
print(x[1],x[2])
f.close()

34 ROLL_NO
Degree=8,Cardinality=5
Insert into Result values(108,'Aadit',470,444,475,'I');

Update Result sem2=sem2+0.03*SEM2


where sname like N%
oR
Delete from Result where Division='IV';
Alter table Results
add Remarks varchar(50);

Q35
pickle
open("extra.dat","wb")
pickle.load(fin)
pickle.dump(rec,fout)

Sample set-6
1.True
2.a object-oriented programming
3(d) Real
4 (a) dict_exam.update(result)
5(b) T[2]=-29
6 (a) ['KV S', 'gath', ' ']
7 (d) Error
8 tuple
list of tuples
9(b) Drop Table
10d) nry iy
11 Distinct
12 (a) File_object.seek(offset[,reference_point])

13
Advanced Research Project Agency Network
Transmission Control Protocol/Internet Protocol

14 (a) 14.75

15 (c) count(*)
16 (b) database
17(b) Both A and R are true and R is not the correct explanation for A
18(b) Both A and R are true and R is not the correct explanation for A
19

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
------------
20
Hub Switch
Shared bandwidth Dedicated Bandwidth
broadcasts data Filters data
or
HTTP FTP
To transfer webpages To upload and download files
to/from a remote server
Hypertext Transfer Protocol File Transfer Protocol

21 5 // 10 * 9 % 3 ** 8 + 8 – 4
0+8-4=4
**
// * %
+-
b) 65 > 55 or not 8 < 5 and 0 != 55
T or not F and T
T or T and T
T
22 Foreign key ia s field used to link multiple tables for referential integrity.
It may be derived from the primary key of some other table
student Teacher
No Name No TID
1 Ram 1 101
2 Sam 1 102
3 Tom 1 103
2 102
3 101
No is the foreign key of table teacher

23 Web server is a software that resides in the server


machine that accepts requests from client machine
and send result as HTML code to browser
Eg :Google web server ,Amazon web server
or
Web hosting is a technique that transfers
the application residing in the client to server
so that the users on the Internet can access

A
Linear architecture and easy to extend
Short cable length
Easy to add and remove nodes

D
If the central cable fails the entire network fails

Repeater must be added in long transmission which


results in additional harware cost

Difficult to detect and isolate faulty computers

24
{"Rohan":67,"Ahasham":78,"naman":89,"pranav":79}
67
145
234
313
sum of values of dictionaries sum

or
answer 1 is 1
answer 2 is 4

25
Data Definition Language
Data Manipulation Language

or
Alter Drop DDL
Insert Update DML

26
Event NumPerformers
Wedding 15

max(FeeCharged)
300000

Event NumPerformers Phone FeeCharged


Birthday 10 6546454654 250000
Engagement 12 6546454654 250000
Promotion Party 20 4654656544 300000
Wedding 15 9854664654 100000

27 def count():
f=open("story.txt","r")
c=0
L=f.readlines()
for x in L:
if x[0] in "IM":
c+=1
print("Count of lines starting with I or M",c)

or

def countmy():
f=open("story.txt","r")
c=0
w=f.read.split()
for x in w:
if x in ["my","My"]:
c+=1
print("Count of My/my",c)

Q28
Department avg(salary)
Computer Sc 16500.0
History 30000.0
Mathematics 25000.0

MAX(DOJ) MIN(DOJ )
2021-09-05 2017-03-24
NAME SALARY Department Place
Shiv 21000 Computer Sc Nagpur
Randeep 30000 Mathematics Jaipur
Raman 25000 Mathematics Jaipur
Samira 40000 History Ahmedabad
Shyam 30000 History Ahmedabad

Name Place

Arunan Ahmedabad
Saman Ahmedabad
Randeep Ahmedabad
Samira Ahmedabad
Raman Ahmedabad
Shyam Ahmedabad
Shiv Ahmedabad
Shalakha Ahmedabad
Arunan Jaipur
Saman Jaipur
Randeep Jaipur
Samira Jaipur
Raman Jaipur
Shyam Jaipur
Shiv Jaipur
Shalakha Jaipur
Arunan Nagpur
Saman Nagpur
Randeep Nagpur
Samira Nagpur
Raman Nagpur
Shyam Nagpur
Shiv Nagpur
Shalakha Nagpur

Q29

L=eval(input("Enter a list"))
os=0
for x in L:
if x%2!=0:
os+=x
print("Odd sum is",os)

Q30
st=[]
def push(L):
for x in L:
if x%2==0:
st.append(x)
def pop():
while True:
if st==[]:
break
print(st.pop())

L=eval(input("Enter a list"))
push(L)
pop()

or
def POP(Arr):
if Arr==[]:
print("Underflow")
else:
print("Deleted item is",Arr.pop())

31

Main
/
Admin
| \
Finance Academic

Main Building max number of 150 computers

Switch/Hub in each building to connect all coumputers


Repeater is not neede in the layout as distance does not exceed 100m

Optical fiber

32 a) 105#6#
b)
con1.cursor
mycursor.execute(querry)
con1.commit()

or

a)HELLl&Kk&&&indIA
b)school
con1.cursor()
mycursor.execute("Select * from student
where marks>75")

33Stores large volumes of data in tabular format


Easy to generate
Easy to import to /from excel or database

import csv
def add():
f=open("record.csv","w",newline='')
writer=csv.writer(f)
while True:
id=int(input("Enter id"))
n=input("Enter name")
s=float(input("Enter salary"))
writer.writerow([id,n,s])
ch=input("Add more y/n")
if ch in 'Nn':
break
f.close()
def count():
f=open("record.csv","r")
c=0
reader=csv.reader(f)
for x in reader:
c=c+1
print("Count=",c)
or
import csv
def add():
f=open("furdata.csv","w",newline='')
writer=csv.writer(f)
while True:
id=int(input("Enter id"))
n=input("Enter name")
p=float(input("Enter price"))
writer.writerow([id,n,p])
ch=input("Add more y/n")
if ch in 'Nn':
break
f.close()

def search():
f=open("furdata.csv","r")
c=0
reader=csv.reader(f)
for x in reader:
if float(x[2])>10000:
print(x[0],x[1])

34
i)Roll_No

Degree=9 Cardinality=5
a)
Insert into Result values
(110,' Aadit', 470,444, 475,' I');
b)Update Result
set sem2=sem2+0.03*sem2
where Sname like 'N%';

or

Delete from Result


where Divison='I';

Alter table Result


add remarks varchar(100);

35 pickle
( "temp.dat,"wb")
pickle.load(fin)
pickle.dump(rec,fout)

Sample Paper-7
1.a True
2a) None
3a) Day={1:’Monday’,2:’Tuesday’,3:’Wednesday’}
4c) Error
5b) (10,20,[30,100,50],60,70)
6c) F=open(‘Notes.txt’,’A’)
7b) alter table
8a) update
9d) Line3 and Line5
10 a) count
11c) F=open(“Notes.txt”); print(F.read(10))
12b) DESC, ASC
13 b) Regenerate
14c) 18

16 – (4 + 2) * 5 + 2**3 * 4
()
**
*
-+
16 – 6 * 5 + 2**3 * 4
16 – 6 * 5 + 8 * 4
16 – 30 + 32=18

15
a) Describe
16d) fetchmulti()
17
b) Both A and R are true and R is not the correct explanation for A

18a) Both A and R are true and R is the correct explanation for A

19

num=int(input(“Enter any value”))


----------------------------------------------
for i in range(0,11):
-----------
if num==i:
------------------
print( num+i)
-----------------------
else:
print( num-i)
------------------------
20 Web Browser Web Server
software that software that
resides in client machine resides in server machine

Sends requests to the server accepts requests


and displays from Browser
the returned HTML code process it
as webpage and returns HTML code

or
a)Star b)Bus

21 a)(40,60)
b) 3

[10,15,3,20,4,25,30]

22
After selectingthe primary key from a set of candidate keys the
remaining candidate keys
are alternate keys

Roll Name Adhar Passport


1 XXX 456 123
2 YYY 674 908
3 XXX 777 111

CK->Roll,Adhar,Passport
PK->Roll
AK->Adhar,passport

23 a)https
b Internet Mail Access Protocol
Post Office Protocol

24 11 1
============
Value=100//9=11
Value =11-10=1

or

12.0
35.0
24.0
14.0

CNT Total C T
3 0 7 '5'
5.0+7=12.0
2 30.0+5=35.0 5 '30'

1 20.0+4=24.0 4 '20'
0 10.0+4=14.0 6 '10'
25
group by clause is to divide a table into groups
having clause to apply condition on a grouped table
Data definition Language----- Alter,Drop
Data Manipulation Language---- Select,Insert

26 a)
COUNT(DISTINCT Number)
2
MAX(ScheduleDate) MIN(ScheduleDate)
23-Jan-2004 12-Dec-2003

sum(prizemoney)
59000
AVG(PRIZEMONEY)
11800

b)
Student Teacher
No Name Marks No TID
1 Anil 90 1 T1
2 Raj 60 3 T2
3 Rekha 70

No Name Marks No TID


1 Anil 90 1 T1
3 Rekha 70 3 T2

Equijoin is a restricted join


that produces a table
based on the equality of values in identical columns
in both tables and duplication of column name occurs

27
def count():
uc=lc=0
f=open("story.txt","r")
s=f.read()
for x in s:
if x.islower():
lc+=1
elif x.isupper():
uc+=1
print("Upper count=",uc)
print("Lower count=",lc)

28
a)Select *
from Product
where PNAME="PC" and stock>100;
b)Select Company
from product where warranty>2;
c) Select company,count(*)
from product group by company;
d) Select Pname from Product;

e) count(distinct company)
4
f) max(price)
39000

29def Shift(Lst):
for i in range(0,len(lst),2):
Lst[i],Lst[i+1]=Lst[i+1],Lst[i]

30
st=[]
def PUSH(A):
for x in A:
if x%2==0:
st.append(x)
if st==[]:
print("Underflow")
else:
for i in range(-1,-len(st)-1,-1):
print(st[i])
or
def popstack(Lst):
if Lst==[]:
print("Underflow")
else:
return Lst.pop()

31 i)
A
/ \
S R
|
P
ii)Research Lab
iii)As per the layout repeater can be placed between Accounts and store
as distance exceeds 100m
Hub/Switch is placed in every building to connect all computers
in each building

iv) Firewall
v)VideoConferencing-Service
Voice Over internet Protocol-Protocol

32 a)option ii and option iv


30%40%50% 40%50%60%

From 1/2/3
To 2/3/4

From 1 To 3 From 2 To 4

b)con1.cursor()

mycursor.execute(querry)
con1.commit()
or
a) cBsE@EXAM@3134
b) Update Product set price=price+50;

33import pickle
def CreateFile():
f=open("Toy.dat","wb")
while True:
TID=int(input("Enter the ID"))
Toy=input("Enter Toy")
Status=input("Enter status")
MRP=float(input("Enter price"))
L=[TID,Toy,Status,MRP]
pickle.dump(L,f)
ch=input("Add more y/n")
if ch in 'Nn':
break
f.close()

def OnOffer():
f=open("Toy.dat","rb")
try:
while True:
L=pickle.load(f)
if L[2]=="On OFFER":
print(L[0],L[1])
except EOFError:
pass
or
import pickle
def CreateFile():
f=open("ITEMs.dat","ab")
while True:
ID=int(input("Enter the ID"))
G=input("Enter Gift")
C=float(input("Enter price"))
L=(ID,G,C)
pickle.dump(L,f)
ch=input("Add more y/n")
if ch in 'Nn':
break
f.close()
def Economic():
f=open("ITEMs.dat","rb")
try:
while True:
L=pickle.load(f)
if L[2]>2500:
print(L[0],L[1])
except EOFError:
pass

34
a)Scode
b)Degree=4 Cardinality=6
c)
Insert into sports(Scode,SportName,Noofpalyers)
values('S007','Kabbadi',15);
or
d)iii) ALTER TABLE SPORTS DROP Coachname

35
a)csv
b)writer(f)
c)writerow(x)
d)close()
Sample Set-8
1 (c) 4ever
2 5+2**6<9+2-16//8
5+64<9+2-16//8
5+64<9+2-2
69<9+2-2
69<11-2
69<9
(b) False **
//
+ -
<

3) True
4) (c) tp1 = tp+tp*2
5 (b) Python $pro$gramming is fun!
6 (a) myfile = open(‘c:\\test.txt’,’rb+’)
7 (b) LIKE
8 (b) SELECT DISTINCT
9(a) Statement 1 and 2
10(c) Candidate keys
11(c) dump()
12(a) ALTER TABLE
13(b) MAN
14 (b) 13.0

(5*2-5//9+2.0+bool(100))
10-5//9+2.0+True
10-0+2.0+True
10+2.0+True
13.0
15 (a) GROUP BY
16 (b) fetchone()
17 (b) Both A and R are true and R is not the correct explanation for A
18.(a) Both A and R are true and R is the correct explanation for A

def prime (num):


-----------------------------
factorial = 1
if num < 0:
print("Sorry, factorial does not exist for negative numbers")
elif num == 0:
-----------------------------
print("The factorial of 0 is 1")
else:
for i in range(1,num + 1):
factorial = factorial*i
--------------------------------
print("The factorial of",num,"is",factorial)

20 Hub broadcasts data to all devices,has shared bandwidth


and traffic congestion occurs and is slower
Switch filters data to a specific devices,has dedicated bandwidth
no traffic congestion occurs and is faster
or
Bus Topology is a linear architecture
Star Topology has a central node to which all devices are connected

Advantages of star
Centralised Control
Easy to detect and remove defecty nodes

Disadvantages
Not easy to extend in case of distant nodes
If central node fails entire network fails

21
a)
name = ‘ Karim Benzema’
index=0
while index<len(name):
print(name[index].upper(),end=’’)
index+=1

b)
Sidhi scored 65 marks in Pre Board
Prakul scored 62 marks in Pre Board
Suchithra scored 66 marks in Pre Board
Prashant scored 49 marks in Pre Board and needs imporovement.
Arun scored 55 marks in Pre Board

22 Referential integrity is a concept that ensures


that when you make changes to data in one place,
those changes are reflected in other related records.
This is done by enforcing a rule that says that the
foreign key in one table can only refer to the primary key of another table

DBMS uses simple SQL commands to store ,retrieve,update


and delete records from the tables unlike file systems which require
more programming instructions
Data is stored as tables in RDBMS which is in an organised manner

23 a) i)Simple mail Transfer Protocol


ii)Internet Mail Access Protocol
b)
Media Access Control is the physical address
assigned to NIC by the manufacturer
and is unique

24 Output is 190
==============
s
0 +20+22+24+60+64 01234
190
or

9 60 P$R$S$
==============
Times Alpha Add C
0 '' 0 1
1 P$ 20 3
4 P$R$ 30 5
9 P$R$S$ 60
25
a) char is fixed length varchar varying length
extra spaces padded no extra spaces padded
wastage of memory no wastage of memory
or
All those keys which have the chances of becoming a primary key
are candidate keys
After selecting primary key from a set of candidate keys
the remaining candidate keys are alternate keys

26
a)
NAME TDATE AMOUNT
AAKASH 2022-08-31 1500
INDIRA 2022-09-15 2000
b)
i)ANO ANAME
103 Ali Reza
105 Simran Kaur

ii)ANO
101
102
103

ANO COUNT(*) MIN(AMOUNT)


101 2 2500
103 2 1000

COUNT(*) SUM(AMOUNT)
2 5000

27import os
def ChangeGender():
f=open("Biopic.txt","r")
t=open("temp.txt","w")
s=f.read().split()
for w in s:
if w=="he":
w="she"
t.write(w+' ')
f.close()
t.close()
os.remove("Biopic.txt")
os.rename("temp.txt","Biopic.txt")

or

def BIGWORDS():
f=open("CODE.txt","r")
s=f.read().split();tc=0
for x in s:
c=0
for y in x:
if y.isalpha():
c=c+1
if c==5:
tc=tc+1
break
print(" Count of big words is",tc)

28
a)
TRAVELDATE
2018-12-25
2018-11-10
2018-10-12

MIN (TRAVELDATE) MAX (TRAVELDATE)


2018-10-12 2018-12-25

START COUNT(*)
Pune Junction 2
New Delhi 2

TNAME PNAME
Amritsar Mail R N AGRAWAL

b)
Describe

29
def ZeroEnding(SCORES):
sum=0
for x in SCORES:
if x%10==0:
sum=sum+x
print("The sum is",sum)
30
status=[]
def push_element(S):
for x in S:
if x[2]=='CS' and x[1]>75:
status.append([x[0],x[1])
def pop_element():
while True:
if status==[]:
print("Stack Empty")
break
else:
print(status.pop())
L=[[“Danish”,80,”Maths”],
[“Hazik”,79,”CS”],
[“Parnik”,95,”Bio”],
[“Danish”,70,”CS”],
[“Sidhi”,99,”CS”]
]
push_element(L)
push_element()
or
st=[]
def Push(emp):
c=0
for k,v in emp.items():
if v<15000:
st.append(k)
c=c+1
print("The count of elements in the stack is",2)

31
i)Administrative Office
ii) AO
/ | \
OU PU Neurology
iii) Switch
iv)Firewall
v)Ethernet Cable

32
a) dcba

b)
db1.cursor()

Update EMP
set salary=salary+1000
where salary<80000;

db1.commit()
OR
a)when K=2
Maximum=1
Minimum=0

Wait # Stop #

R=random.randrange(start,stop,step)
start<=R<stop step is 1
0<=R<2
K=1
0<=R<1
b)
con1.cursor()
mycursor.execute(querry)
con1.commit()

33
Comma Seperated Value Files
import csv
def writerec():
f=open("plants.csv","w",newline='')
writer=csv.writer(f)
while True:
ID=int(input("Enter ID"))
NAME=input("Enter Name")
PRICE=float(input("Enter price"))
writer.writerow( [ID, NAME, PRICE])
ch=input("Add more y/n")
if ch in 'Nn':
break
f.close()

def showhigh():
f=open("plants.csv","r",newline='')
reader=csv.reader(f)
for x in reader:
if float(x[2])>500:
print(x[0],x[1])
f.close()
writerec()
showhigh()

or
Text Binary
No module pickle module needed
EOL translations No EOL translations
UNICODE format Machine format
User friendly Machine friendly
Slow processing Fast processing

def countrec():
f=open("patients.csv","r")
c=0
reader=csv.reader(f)
for x in reader:
if x[2]=="COVID_19":
c+=1
print("Total number of patients=",c)
f.close()

34
a)Degree=5 Cardinality=6
b)Movieid because it is not empty and do not have duplicate values
c)
i)Delete from Moviedetails where rating<4
ii)Update MOVIEDetails
set rating=5
where MOVIEID='M020';
or
i) Alter table MOVIEDETAILS
add Recommended varchar(10)
Default 'Recommended';
ii)Update MOVIEDETAILS
set rating=rating+1
where language='Hindi';

35
a)import pickle
b)
open("Mydata.dat","wb")
open("Mydata.dat","rb")
c)
pickle.dump(sqlist,fout)
mylist=pickle.load(fin)
Sample Set-9
1 False
2 16 - 30 + 32=18 c
3 (c) a
4 d)**
5 d)4map
6b)random
7[]
8d) Server
9c) flush()
10 b) Stop
11 (a) SMTP,POP
12 b) ALTER
13a. read()
14 a. 0
15c. (comma) ,
16(b) commit()
17(a) Both A and R are true and R is the correct explanation for A
18(a) Both A and R are true and R is the correct explanation for A

19
def swap(d):
-----------------
n = {}
values =list( d.values())
----------------------
keys = list(d.keys())
-----------------
k=0
for i in values:
n[i] = keys[k]
----
k+=1
-------
return n
result = swap({‘a’:1,’b’:2,’c’:3})
print(result)

20 Cookies are plain text files send


from server machine to client machine
to keep track of user activity on Internet

A
---
Can create customize webpages for user
D
---
May carry virus or worms which can be a threat to system

or
Client side Server side

Script Script
Executes executes
in the in the
browser server

it is downloaded It is not
in the client downloaded in the client machine
machine and
is send by the server

Database not needed Database needed


JavaScript PHP

21
a) prOgRaMmIn
b) 11
22
Data Definition Language affect structure of table
Create,Alter
Data Manipulation affects records in a table
Insert, Delete

23 Wireless Local Arean Network


Worl Wide Web

24
Hub is a centralised distribution node
to connect all computers in a network

Active hub regerates the weak signals and


Passive hub simply passes the signal along with the noise

24
250 300
==========
var1=var1+10=50+10=60 100+10=110
var2=var2-10=200-10=190 200-10=190
or
50#5
=========
N value
20 50->25->5
25 Primary key Unique
===============================================
A table can have only one primary key A table can have more than one unique key
Cannot be NULL can be NULL
create table student(rollno integer primary key,
adhar varchar(20) unique,
pancard varchar(15) unique));
or
where having
applied before group by applied after group by

cannot work with can work with


aggregate functions aggregate functions
Yes can be used together
Select department,count(*)
from employee where gender='F' group by department having count(*)>=2;
26
a)
ItemNo Item Scode Qty Rate LastBuy Scode Sname
2005 SharpnerClassic 23 60 8 31-Jun-09 23 Soft Plastics
2003 Ball Pen 0.25 22 50 25 01-Feb-10 22 Tetra Supply
2002 Gel PenPremium 21 150 12 24-Feb-10 21 Premium Stationers
2006 Gel PenClassic 21 250 20 11-Mar-09 21 Premium Stationers
2001 Eraser Small 22 220 6 19-Jan-09 22 Tetra Supply
2004 Eraser Big 22 110 8 02-Dec-09 22 Tetra Supply

=====================================================

i
City
------
Delhi
Mumbai
Bangalore

ii ItemName MAX(Price) Count(*)


Personal Computer 37000 3
Laptop 57000 2

iii CustomerName Manufacturer


K Agarwal ABC
H Singh XYZ
R Pandey Comp
C Sarma PQR
N Roy PQR

ivItemName Price*100
Personal Computer 3500000
Laptop 5500000

27 def count():
f=open("India.txt","r")
w=f.read().split()
c=0
for x in w:
if x.upper()=='INDIA':
c+=1
print("Count=",c)
or
def biglines():
f=open("content.txt","r")
L=f.readlines()
for x in L:
if len(x)>20:
print(x)

28 i) SenderCity
--------------
New Delhi
Mumbai

ii)SenderName RecName
--------------------------------------
R Jain H Singh
S Jha P K Swamy

iii) RecName RecAddress


---------------------------
S Mahajan 116, A Vihar
S Tripathy 13, B1 D, Mayur Vihar

iv) RecID RecName


----------------------------
ND48 S Tripathy
ND08 S Mahajan

29

def SwitchOver(Val):
for i in range(0,len(Val),2):
Val[i],Val[i+1]=Val[i],Val[i+1]
print(Val)

30
NoVowel=[]
def PushNV(N):
for x in N:
for y in x:
if y.upper() in "AEIOU":
break
else:
NoVowel.append(x)
def Pop():
while True:
if NoVowel==[]:
print("Empty Stack")
break
else:
print(NoVowel.pop())
ALL=[]
for i in range(5):
s=input("Enter a word")
All.append(s)
PushNV(ALL)
Pop()
or
Only3_5=[]
def Push3_5(N):
for x in N:
if x%3==0 or x%5==0:
Only3_5.append(x)
def Pop():
while True:
if Only3_5==[]:
print("Empty Stack")
break
else:
print(Only3_5.pop())
NUM=[]
for i in range(5):
x=int(input("Enter a integer"))
NUM.append(x)
Push3_5(NUM)
Pop()
31
i)HR Unit
Training
ii) /
HR Star topology
/ \
Media Design
iii) Switch
iv) Ethernet Cable
v)Voice Over Internet Protocol

32 a) 5#8#5#4

L [25,8,75,12] M N 4
5 5 4
0 1 2 3

b)
db1.cursor()

Delete from category


where name="Stockable";

db1.commit()

or

a)
pYTHOnN#.
b)
1)
i.mysql.connector as ms
ii.mycursor.execute("Select *
from teacher where dateofretire
between '2022-01-01' and '2022-12-31')

iii mycursor.fetchall()

33
w a
truncates the does not truncate
contents of the existing
file

overwrite the entire content writes only to the end of the file

import csv
def addcsv(username,password):
f=open("login.csv","w",newline='')
writer=csv.writer(f)
writer.writerow([username,password])
f.close()

def checkDetails(username,password):
f=open("login.csv","r"');
reader=csv.reader(f)
for x in reader:
if x[0]==username and x[1]==password:
return True
else:
return False

read->load()
write->dump()

import csv
def insertdata():
f=open("customerdata.csv","w",newline='')
writer=csv.writer(f)
while True:
cn=input("Enter name")
mn=input("Enter mobile")
dp=input("Enter purchase date")
ip=input("Enter item")
writer.writerow([cn,mn,dp,ip])
ch=input("Add more y/n")
if ch in 'Nn':
break
f.close()

def frequency(name):
f=open("customerdata.csv","r"');
reader=csv.reader(f)
c=0
for x in reader:
if x[0]==name:
c+=1
print(name,"purchased",c,"times")
f.close()
34
i No. Name Age Dateofadm
ii Degree=7 Cardinality=10
iii a)Delete from Hospital
where Name like 'Z%';
b)Update Hospital
set charges=1000
where Name='Ankita'
or
iii a) Desc Hospital;
b) Update Hospital set age=age+2;

35
a open("student.dat","wb")
b pickle.dump(Stul,fh)
c.with open("student.dat","rb") as fin:
d. Rstu=pickle.load(fin)

Sample paper -10

1.(iii) Pea Cock


2 i) Keyword ii) identifier
3 vemyCou
4 300 # 100
300 # 200
240 # 200
5 a) Move file pointer five character ahead from the current postion
6b)writelines(list)
7a) True
False
8c) Error
9 a)dict.keys()
10 a)Create an instance of a cursor
11d) All of the above
12b) Flase
13d) DISTINCT
14c)IS
15b) ghagwal
16 d) SMTP
17a) Both A and R are true and R is the correct explanation for A
18b) Both A and R are true and R is not the correct explanation for A

19
x5=int( input(“Enter a number”))
----------
if ( abs(x)==x):
----------------
print(“You Entered a positive number..”)
----
else:
-------
x=x-1
print(“Number made positive:”,x)
----

20 Parameters with predefined values in the function head are default parameters
Arguments with predefined values in the function call are keyword parameters

def swap(a,b=10): #default parameter b


print(a,b)
swap(b=20,a=30) # order need not be same and parameters explicitly taken
from function head
b=20 and a=30 are keyword parameters
or
Local Global
variables variables in the main or above all functions
inside
a function
a=10 #global
def show():
b=20 #local
x=90 #global
show()

21a) $$$$$$$Sequence with labels$$$$$$


b)( 'a', '3’,'sum', '4')

22 order by-to arrange records in ascending or descending order


having to specify a condition after grouping a table after group by

23 a)Internet Mail Access Protocol


b)Post office Protocol

24 kVS^NISHANT^3134

25 min value of Y=0


max value of Y=4
X 0.0<=X<1.0 Y=0/1/2/3/4

i) 0:0 iv)0:3

26 Max(Price) Min(QTY_Store)
15000 100
QUARTER SUM(QTY SOLD)
1 49
2 19
3 12

WATCH_NAME QTY_STORE SUM (QTY_SOLD)


High Time 100 22
Life Time 150 23
Wave 200 26
High Fashion 135 9

27 def copy() :
f=open("Text1.txt","r")
t=open(("Text2.txt","w")
s=f.read().split()
for w in s:
if w[0] not in "AEIOU":
t.write(w+' ')
f.close()
t.close()
or
def countmy():
f=open("Data.txt","r")
c=0
s=f.read().split()
for x in s:
if x in ['my','My']:
c=c+1
print("Count of my=",c)
f.close()

28 COUNT(*) VCODE
2 V01
2 V02

VCODE CNAME VEHICLETYPE


V02 Ravi Anish AC DELUX BUS
V04 John Malina Car

Vcode
V01
V02
V03
V04
V05

29 def fun(S):
uc=lc=0
for x in S:
if x.isalpha():
if x.isupper():
uc+=1
elif x.islower():
lc+=1
print("No. of Upper case characters :",uc)
print("No. of Lower case characters :",lc)
30
st=[]
def PUSHON(Student):
st.append(Student)
def pop(Student):
if st==[]:
print("Empty")
else:
student=st.pop()
print("Popped item is",student)

31 a) LAN WAN
b)i) Switch/Hub
c)ii) Optical fibre
d)Sales - Tech
Office Office
\
Head Office
Satellite communication is the technology
32
st=[]
def PUSHEI(element):
st.append(element)
def pop(element):
if st==[]:
print("Empty")
else:
element=st.pop()
print("Popped item is",element)
or

st=[]
def PUSH(A):
for x in A:
if x%2==0:
st.append(x)
if st==[]:
print("Empty")
else:
for i in range(-1,-len(A),-1):
print(A[i])

33
def countVowels():
f=open("myfile.txt","r")
s=f.read();vc=0
for x in s:
if x.upper() in "AEIOU":
vc+=1
print("Vowel count=",vc)
f.close()

34
i)Select M_company,M_Name,M_price
from MobileMaster order by M_Mf_Date
desc;
ii) Select * from MobileMaster
where M_name like 'S%';

iii)Select M_Supplier ,M_Qty


from MobileStock where
M_ID not like 'MB003';

iv) Select M_company from MobileMaster


where price between 3000 and 5000;

v)Select M_company,M_Supplier,M_price
from MobileMaster natural join MobileStock
and M_price>5000

35
a)csv
b) 'a'
c) reader
d)close()
e)
Note Book 45 100
Text Book 60 150
Ball Pen 10 100
Pencil 5 200

Sample set-11
1. 5/(6*2) and 5/6*2
0.4 and 1.6 False
2.(b) String
3 a. del Dict1[‘Dictionary’]
4 32+2*7-2
32 +14-2=44

(a) 44

5 (D) [ ] @ [78, 45, 36, 23, 10]


6(b) Python gives error if the file does not exit at the specified path.
7 NULL
8(C) ALTER TABLE EMPLOYEE DROP SALARY;
9(B) ALTER TABLE
10 +
11(C) It places the file pointer at a desired offset within the file
12(B) Specifying number of bytes.
13Repeater
14 0
15count(*)
16(B) and (C) Connect(host=”host name”, user=”user name”, password=”password”,
database= “database name”)
17(A) Both A and R are true and R is the correct explanation for A.
18(B) Both A and R are true and R is not the correct explanation for A.
19
def Factorial(Num):
___
fact=1
---------
while num>=0:
--------------------
fact=fact*num
num-=1
--------------
print(“Factorial value is =”,fact)

20
Virus replicates itself and worms donot replicate
Virus requires an independent host whereas worm
does not require a host and spreads through networks

or
Web Browser and Web Server already discussed
21 A)[37,61,89]
B)Lib.pop('Novel')

22 Unique Primary
can have Null values cannot have Null values
more than one unique only one primary
key allowed key in a table
in a table

23
A File Transfer Protocol
Global System for Mobile Communication

B Metropolitan Area Network (MAN)

24 cbse#3134 #eXAMS
or
57
{(1,2,3):12,(4,5,6):20,(1,2):25}

25 Degree :No: of colums


Cardinality is the number of rows
or
Data Definition Language Alter,Create
Data Manipulation Language Select,Update
26
A)
Ecode Ename Department
M01 Bhavya Marketing
S01 Mehul Sales
A05 Vansh Accounts
H03 Pallavi HR

P_Name count(*)
Talcum Powder 1
Face Wash 2
Bath Soap 1
Shampoo 1

Max(Price) Min(Price)
120 40

P_Name C_Name
Face Wash Total Health

P_Id P_Name C_Name City Price


FW05 Face Wash Total HealthMumbai 45

27
def COUNT_UPPER():
f=open("CONTENT.TXT","r")
uc=0
for x in f.read():
if x.isupper() and x.isalpha():
uc+=1
print("The number of uppercase alphabets in the file :-",c)

or
def COUNT_WORD():
f=open("PLEDGE.TXT","r")
wc=0
for x in f.read().split():
if x=='country':
wc+=1
print('Total Occurrences of word “country” =',c)

28
COUNT(DISTINCT Make)
4

MAX(Charges) MIN(Charges)
20 14

Count(*) Make
2 Suzuki
1 Tata
1 Toyota
1 Hyundai

CarName
Innova
B) show databases;

29
def R_shift(Arr,n):
L1=Arr[n:]
L2=Arr[:n]
print(L1+L2)
or
def R_shift(Arr,n):
for x in range(n):
T=Arr[-1]
N=len(Arr)-1
for i in range(N,0,-1):
Arr[i]=Arr[i-1]
Arr[0]=T
print(Arr)
Arr=[33,11,44,66,22]
n=int(input("How many shifts"))
R_shift(Arr,n)

Q30
book=[]
def push_rec():
while True:
bn=input("Enter book name")
an=input("Enter author name")
pr=float(input("Enter price"))
if pr>500:
book.append([bn,an,pr])
ch=input("Add more y/n")
if ch in 'Nn':
break
def pop_rec():
while True:
if book=[]:
print("Stack underflow")
break
print(book.pop())

or
stack=[]
def push(item):
c=0
for it in item:
if it[1]<50:
stack.append(It[0])
c+=1
print("The number of elements in stack is : ",c)

31i) Human Resources


ii)
HR->CB
|
FB
iii) b)Satellite
iv) Hub/Switch in every building
Repeater needed between buildings where distance exceeds 70m
So can be kept bw Conferebce and Finance blocks
v) Service -Videoconferencing Protocol-VOIP

32A)
21@12@ a=4+20-3=21 a=10+5-3=12
B)mycon.cursor()
mycursor.execute(Qry_Str)
mycursor.fetchall()
or
A)
#
$
$$
$$$
##
$
$$
$$$
###
$
$$
$$$
B mycon.cursor()
mycursor.execute(Qry_Str)
mycursor.commit()

33 reader object is an iterable that can be processed using a loop


Each row returned by the reader is a list of String elements containing the data found by removing the
delimiters
import csv
def add_user():
f=open("users.csv",newline=" ")
writer=csv.writer(f)
while True:
uid=input("Enter ID")
pwd=input("Enter password")
writer.writerow([uid,pwd])
ch=input("Add morey/n")
if ch in 'Nn':
break
f.close()
def search():
f=open("users.csv")
reader=csv.reader(f)
uid=input("Enter ID");ff=0
for x in reader:
if x[0]==uid:
print(x[1])
ff=1
break
if ff==0:
print("No such user")
f.close()
or
Comma-separated values (CSV) is a text file format that
uses commas to separate values, and newlines to separate records.
A CSV file stores tabular data in plain text,
where each line of the file represents one data record.
import csv
def writeCsv():
f=open("stud.csv",newline=" ")
writer=csv.writer(f)
while True:
r=input("Enter roll")
n=input("Enter name")
m=float(input("Enter marks"))
writer.writerow([r,n,m])
ch=input("Add morey/n")
if ch in 'Nn':
break
f.close()

def readcsv():
f=open("stud.csv",'r')
reader=csv.reader(f)
for x in reader:
print(x[0],x[1],x[2])
f.close()

34
i) GCODE
ii)Degree=5 Cardinality=5
iii
a)Update Gamesset prizemoney=prizemoney+0.2*prizemoney;
b)Select Gname,PrizeMoney from Games where Gname like 'C%';
or
a)Alter table Games
add NoofPlayers int;
b)Select sum(prizemoney)
from Games;

35
i) pickle
ii) 'student.dat','rb'
iii) pickle.load(fin)
iv) rno==rec[0]

Sample Set-12
1 (B) ^ (C) =+ (D) &&
2(D) rstrip( )
3 (B) PYT
4(B) Aditi
5(D) 300
6(A) Underflow
7(A) Pickling
8(D) All of Above
9(C) None
10(B) Protocol
11(C) CREATE, DROP, ALTER, MODIFY
12B) SELECT DISTINCT(city) FROM Exam
13(C) SELECT Movie_Name FROM MOVIE WHERE Movie_Name LIKE ‘%No-1’;
14(C) BOTH A and B
15(C) TCL Command
16 D)cursor()
17 (a) Both A and R are true and R is the correct explanation for A
18(c) A is True but R is False
19 def pattern(start, end, interval):
______________-
for n in range(start, end, interval):
____________
if(n%2==1):
print(n)
else:
---------------------
pass
x=int(input("Enter Start Number: "))
y=int(input("Enter End Number: "))
z=int(input("Enter Interval: "))
pattern(x,y,z)

Q20
A)2022
B)
dict_values(['Tiger','Peacock','Tri-Color','New Delhi'])

21
A B
100 200
P 20000 Q100

20000#100.0
100.0$200 B 200 Q 10 P2000
2000#200.0 200
100.0$200.0 / is real

22 Uniform Resource Locator


Simple Mail Transfer Protocol
23 Webpage is a document in a website
Website is a collection of related webpages
Google homepage is a webpage
google.com is a website
or
Packet switching has no physical connection
Uses store and forward principle

Circuit switching has a dedicated physical connection


Do not uses store and forward principle

24 connect()creates a connection object


to create a unique session between Python and database

rowcount is a property to countthe number of rows


fetched

25To create multiple fields which can have Null


values but cannot have duplicate values
create table student(roll int primary key,
adharno int unique,
passport int unique);
Here adharno and passport cannot have duplicate
values but can have Null values
or
degree is the number of columns
cardinality is the number of rows
Roll Name
1 Raj
2 Sunil
3 Rekha
Degree -2
Cardinality-3

26
def COUNT_WORDS():
f=open("Student.txt','r')
s=f.read().split()
c=0
for w in s:
if w[0]=='S' and w[-1]=='R':
c=c+1
print("Total count=",c)

27
def How_Many(List, elm):
c=0
for x in List:
if elm==x:
c=c+1
print(elm,"found",c,"Times")

28
def PUSH_CITY(cities):
cn=input("Enter city name")
cities.append(cn)
def POP_CITY(cities):
if cities==[]:
prin("Underflow")
else:
print(cities.pop())
or
st=[]
def PUSH_val(val):
for x in val:
if x%2!=0:
st.append(x)
if st==[]:
print("EMpty")
else:
for i in range(-1,-len(st)-1,-1):
print(st[i])

29
A
TEACHER SUBJECT GENDER
Ganan Physics Male

Designation Count (*)


Vice Principal 1

max(Experience)
16

Teacher
Umesh
YashRaj
count(*) Gender
5 Male
2 Female

30
SUM (PERIODS) SUBJECT
51 English
76 Physics
24 Maths
27 Chemistry

TEACHERNAME GENDER
Priya Rai Female
Lisa Anand Female

COUNT (DISTINCT SUBJECT)


4

Q31
a)
J
\
S_H
/ Star topology
A Optical Fiber

b) Wing S because maximum no: of computers


c)Hub/Switch in every building
d)Wifi Router
e)LAN

Q32A)
***D-*U**P202

B)
con.cursor()

EmpCursor.execute("Select *
from Emp where salary>50000")

EmpCursor.fetchall()

33
Text Binary
Unicode Machine
No module Pickle module
Delimiter needed No delimiter
Slow Fast

B)
import csv;f=open("library.csv","w",newline='');writer=csv.writer(f)
def ADD_BOOK():
while True:
bid=int(input("Enter id"))
bn=input("Enter name")
bp=float(input("Enter price"))
L=[bid,bn,bp]
writer.writerow(L)
ch=input("Add more y/n")
if ch in 'Nn':
break
f.close()

def show_Book():
f=open("library.csv","r");reader=csv.reader(f)
for x in reader:
if float(x[2])>500:
print(x[0],x[1])
f.close()

Q34
i) emp_id
degree=7 cardinality=5
ii) Alter table salary drop primary key;
iii)
Update salary
set HRA=HRA+0.01*basic;
iv)
select emp_name,emp_desig
from emp
where basic between 50000 and 80000;

Q35
open("Sports.dat","ab")
picle.dump(record,fopen)
pickle.load(F)

Sample set-13
1 math
random
2 import
3 Key “Rohan”
Value{“Manager”:427, “SBI”, 05884 }
4 c) ==
5 7
6 b. fp.tell( )
7 b. group by
8 distinct
9 .50
10 c. Cardinality
11 d. f= open(“Students.txt”, ‘A’)
12 HAVING
13 Point to point protocol
Voice over Internet Protocol
14 (20,22)
15 c. JOIN
16 mysql.connector
17 Both A and R are true and R is not the correct explanation for A
18Both A and R are true and R is not the correct explanation for A
19
marks = int(input(“enter marks”))
------------------------------------------------
temperature = float(input(“enter temperature”))
------------------------------------------------------------
if marks < 80 and temperature >= 40:
------------------------------------
print(“Not Good”)
else:
------
print(“OK”)
20
Web hosting transfers the files
from the client to server machine
so that it can be readily accessed
by the users of the Internet

or
Transmission Control Protocol/Internet Protocol
TCP
1.divides a message into packets at the sender machine
2 Reassemble the packets into message at the destination
3 ensures packets reach teh destination
IP
1 .routes the packets using IP address
2.decides the number of packets and size of each packet

21
a)
7+9*5//8-3
7+45//8-3
7+5-3
12-3
9
==

b) False and True or not False


False and True or True
False or True
True

22 Constraints are conditions applied at column or table level


create table student(roll integer primary key,
gender char(3) default 'M',
adhar varchar(10),
passport varchar(10),
unique(adhar,passport));

23
Personal Area Network
Hypertext Markup Language
Uniform Resource Locator
Post Office Protocol

24
24
65

or
47
35
54
26

25
DDL DDL
or
char(n)- fixed length
spaces padded
wastage of memory space
varchar(n)-varying length
no spaces padded
no wastage of memory space
gender char(5) gender varchar(5)
F---- 5bytes F 1 byte
26

Degree=4
Cardinality=5

MIN(AVERAGE)
63
SUM(STIPEND)
800
AVG(STIPEND) ( 68+68+70+68)/4
68.5
COUNT(distinct SUBJECT)
4

27
def calculate():
f=open("ABC.txt','r')
s=f.read()
c=0
for x in s:
if x.isdigit():
c=c+1
print("Total count=",c)

or
def count():
f=open("story.txt','r')
s=f.read().split()
c=0
for w in s:
if w=='the':
c=c+1
print("Total count=",c)
28
ename salary
Priya 60000

count(salary)
2
max(joindate) min(joindate)
2020-02-16 2019-10-11
29
def Msearch(States):
for x in States:
if x[0]=='M':
print(x)
30
def PUSH(S,item):
S.append(item)
or
def POP(S):
if S==[]:
print("Underflow")
else:
print(S.pop())
Q31
a)
A
\
C-B
/ Star topology
D

b) Block C because maximum no: of computers


c)Repeater between B and C ,A nd C as distance exceeds 70m
d)Radio waves
e)In every building to connect each computer to form a network

Q32A) KVisONtheTOP
B)mysql.connector as
connect database
cursor()
query
close()

or

56 5 44
s m n
0 0 0
2 4
6 5
12 11
20 20
30 31
42 44
56

B)
i)mysql.connector
excecute()
connector.connect (host=”192.168.1.101”, user=”root”,passwd='admin',
database='KVS')
con.cursor()

33 a) csv
b) writerow
c) reader
d)user_id beneficiary
1 xyz
e) close()
or

a) csv
b) r
c) csv.reader
d) close()
e)Comma Seperated Values

34 a) C_ID
b)degree=7
cardinality=4
c) i) delete from company where C_ID='C24';
ii)Update Company set Fees=Fees+500;

Or
i)Alter table Company add Place varchar(20);
ii)Select * from company;

35 w -if the file exists the contents are truncated and data is written
a- if the file exists the contents are not truncated and data is
added to the end

B)
import pickle
f=open("D:\\school.dat","rb'')
c)
import pickle
f=open("employee.dat","rb'')
def show_Book():

try:
while True:
L=pickle.load(f)
if 20000<=L[2]<=30000:
print(L[0],L[1],L[2])

except EOFError:
pass
f.close()

Sample Set -14

1.C. 2ndName
2 B. [6,82,5]
3 f=open("ABC.txt","r")
4 False
5 (10, 20, 30, 40,10, 20, 30, 40)
6 dict_keys(['amit','vishal'])
7 TypeError Item Assignment not possible
8 pow(x,y)
9(c) tuple
10 File Transfer Protocol
11 Total number of rows =6
Name column has 1 NULL value and hence 5
count(Name) counts only NON NUll values

12 where having
works cannot works
with aggregate functions with aggregate functions
can be applied before can be applied after
group by group by

13 ALter table student


add marks int;
14 .Each attribute in a record is a field
A collection of attributes is know as a record

15 Absence of a value

16 % and _

17 e) Both A and R are false


18 c) A is true but R is false.

19 A
Create table student(No integer primary key,
Name varchar(20),
Stipend decimal(5,2),
Stream varchar(20),
avg decimal(5,2),
grade char(1),
class char(3));

B No
C Degree-7 Cardinality-10
D Select *
from student
order by name asc;

E Update student set grade='B' where name='Karan';

20 csv
w
reader
close()
Arjun 123@456
Arunima aru@nima
Frieda myname@FRD

21 a 18+16//5-8=18+3-8=13
b) T and F or not T
T and F or F
F or F
False
===

22
Named argumed with defined values in function call

def show(a,b):
print(a,b)
show(b=10,a=30)
Order need not be maintained
30 10
Scope is the area in which a variable can be seen
Local scope is within a function
Global scope is throughout the program

23
def func(a):
-------------------
for i in (0,a):
-----------------
if i%2 ==0:
----------------------
s=s+1
elif i%5= =0:
----------------
m=m+2
else:
n=n+i
print(s,m,n)
func(15)
-----------

24 i) and ii)
or
200 # 100
200 # 200

25 Write the steps to perform an Insert query in database connectivity application. Table
‘student’ values are rollno, name, age (1,’AMIT’,22)

import mysql.connector as con


db=con.connect(host='localhost',user='root',passwd='root',database="mysql")
cursor=db.cursor()
cursor.execute("Insert into student(rollno, name, age) values(1,’AMIT’,22)")
db.commit()
db.close()

26 connect() creates a connection object to establish an unique session with the database

execute() helps to execute queries

27 Repeater is a network device that regenerates weak signals and


transmit to the destination
A router is a device that connects two or more packet-switched networks
or subnetworks that can handle similar protocols
It routes Internet traffic between these networks by forwarding data packets to their intended IP addresses,
and allowing multiple devices to use the same Internet connection.

28 Web server is a software that resides in the server and responds to


the request of client machine in the form of HTML code
Apache Tomcat
Web Browser is a software that resides in the client and sends request to server
and accepts HTML code and displays as a webpage
Google Chrome

29 def listchange(Arr):
for i in range(len(Arr):
if Arr[i]%2==0:
Arr[i]=10
else:
Arr[i]*=5

30 def count():
f=open('abc.txt','r')
c=0
L=f.readlines()
c=len(L)
print("Count of lines=",c)
or
def count():
f=open('abc.txt','r')
c=0
for w in f.read().split():
if w=='if':
c=c+1
print("Count of words=",c)

31
a) count(discount)
------------------
2
b) manufacturer max(price) min(price)
-----------------------------------------------------
LAK 40 40
ABC 55 45
XYZ 120 95
c ProductName ClientName
FaceWash TotalHealth

Q32 #Consider e as element


st=[]
def PUSEI(e):
e=int(input("Enter an element"))
st.append(e)
def POPEl(e):
if st==[]:
print("Underflow")
else:
e=st.pop()
print("Item popped is",e)

or
st=[]
def Push(Sitem):
c=0
for k,v in Sitem.items():
if v>75:
st.append(k)
c=c+1
print("Count of elements pushed=",c)

Q33
Text Binary CSV
No module pickle module csv module

plain text machine format delimited text in tabular form

No delimiter No delimiter delimiter is comma


programmer must required and new line='\r\n'
add delimiter as it is is automatically attached
to seperate records processed
and fields block by block

can store &retrieve can store and retrieve can read as


string type any list of any datatype
data only type of data but stored as string &
retrieved as
list of strings
Q34
con1.cursor()
mycursor.execute(querry)
con1.commit()

Q35
1 HR center has maximum number of computers
2
BB -TB-HR
|
LB As per shortest distance
or

As per server
HR
/ | \
TB LB BB

c) Hub/Switch
d) As per shortest distance layout repeateris not needed as the distance is not above 100m
e)WAN as distance exceeds 50kms
Q36 Or
import pickle
def add_record():
f=open("stud.dat","ab")
while True:
n=int(input("Enter admission no"))
name=input("Enter name")
marks=float(input("Enter marks"))
L=[n,name,marks]
pickle.dump(L,f)
ch=input("Add more y/n")
if ch in 'Nn':
break
f.close()
def Search_record():
f=open("stud.dat","rb");n=int(input("Enter roll no:"));f1=0
try:
while True:
L=pickle.load(f)
if L[0]==n:
print(L[1],L[2])
f1=1
break
except EOFError:
pass
f.close()
if f1==0:
print("No such record...")
def count_rec():
c=0
f=open("student.dat","rb")
found=0
try:
while True:
L=pickle.load(f)
if L[2]>75:
print(L[1],L[2])
c=c+1
found=1
except EOFError:
pass
f.close()
if found==0:
print("No such record...")
else:
print"Count=",c)

Sample Paper 15
1(b) 2_hello_world
2(c) tuple
3(c) def f(a=3,b=1,c=6):
4(a) random()
5(b) rw
6 To return a value or immediate exit from a function
7 avg()
8(b) [1, 7, 8, 3, 4, 5]
9(b) top
10 (b) Router
11(d) AQL
12(b) select, from
13(b) DML
14(d) Cartesian Product
15(c) cursor
16(c)Street no (d) dept_id
17(c) A is true, but R is false.
18(c) A is true, but R is false.
19
15
15
20Module is a collection of related functions
Facilitates the speed of code and helps in reuse of code
21 read() reads the entire content as a string from a text file
readlines() reads as a list of strings from a text file
22 Insertion in stack is Push and Deletion from stack is pop
Item inserted last is removed first hence it is LIFO
23 Modulation Demodulation
Wireless Local Loop
File Transfer Protocol
Transmission Control Protocol/Internet Protocol
24 URL “https://www.youtube.com/watch?v=90ORfh6a-kM”
Domain Name :www.youtube.com
25 All fields that have the chances of becoming a primary key are
candidate keys .Remaing candidate keys after selecting the primary key
are alternate keys
Roll Name Marks
1 Anil 99
2 Raj 99
3 Sunil 97 CK->Roll,Name PK ->Roll AK->Name
26 Select * from employee where grade IS NULL;
27 def DISPLAYWORDS():
f=open("ABC.txt","r")
for x in f.read().split():
if len(x)>5:
print(x)
28
def max(a,b):
if a%10>b%10:
return a
else:
return b
29l=[3.0,9.0]
['bb','bo','by','ab','ao','ay','lb','lo','ly','lb','lo','ly']

k=[e1*r for e1 in l if (e1-4)>1 for r in l[:4]]


|
V
k=[]
l=[1,2,5,6,7,9,10,22,38]
for e1 in l:
for r in [1,2,5,6]:
if (e1-4)>1:
k.append(e1*r)

[6, 12, 30, 36, 7, 14, 35, 42, 9, 18, 45, 54, 10, 20, 50, 60, 22, 44, 110, 132, 38, 76, 190, 228]

30
def Push(City):
name = input(“Enter city:”)
City.append(name)

def POP(City):
if (City ==[]):
print(“Stack empty”)
else:
print(City.pop())

31 count(*) Dcode
2 D01
2 D05
Department
Media
Marketing
Infrastructure
Finance
Human resource
Name Department City
George K Media Delhi
Ryma Sen Infrastructure Mumbai

32 Aggregate functions min(),sum(),count(),avg(),max()


works on multiple values in a column and returns a single result
Group by is used to divide a table into groups

33
import pickle
def add():
f=open("stud.dat","wb")
while True:
r=int(input("Enter roll"))
n=input("Enter name")
m=float(input("Enter marks"))
s=(r,n,m)
pickle.dump(s,f)
ch=input("Add more y/n")
if ch in 'Nn':
break
f.close()

def search():
f=open("stud.dat","rb");found=0
try:
while True:
s=pickle.load(f)
if s[0]==12 or s[0]==14:
print(s[1],s[2]);found=1
except EOFError:
pass
f.close()
if found==0:
print("No such record...")

34 a) Advantage ->Very fast and secure Disadvantage->Expensive


b) Bus topology Tree topology
connected with a single cable without any interconnection Form of of a tree structure with root
node at top
if central cable fails entire network fails if root node fails entire network fails
Less Expensive Very Expensive

c)FTP is File Transfer Protocol for uploading and downloading files to and from a server
Email is a service in WWW for sending and receiving emails across Internet

d)Bridge is network device to connect dissimilar networks and perform protocol translations
Repeater is a network device to regenerate signals after every 70-100m range

e)Network File Service


File Transfer Protocol
35 i. csv .
ii "Student.csv","w"
iii writer(fh)
or
roll_no,name,Class,section
iv Statement 5 rec
Statement 6 writerows
36 1. SELECT Name, Price FROM ACCESSORIES ORDER BY Price desc;
2. SELECT ID SName FROM SHOPPE WHERE Area=”Nehru Place”;
3. SELECT Name, max (Price); min(Price) FROM ACCESSORIES
Group By Name;
4. SELECT Name,price, Sname FROM ACCESSORIES, SHOPPE
WHERE SHOPPE. ID=ACCESSORIES.ID;

=============================================================================

You might also like