Solvedanswer
Solvedanswer
21a) nuaa l
b)400 420
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
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
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)
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
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
21
a) [10,30,50,70]
b) 16
student
Roll Name Marks
1 Raj 99
2 Anil 99
3 Raj 77
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
Manufacturer
Surf
Colgate
Lux
Pepsodent
Dove
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
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)
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]
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)
or
Optical Fiber Ethernet Cable
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
23
a) Service _VideoConferencing and
Protocol is Voice Over Internet Protocol
24
12.0
35.0
24.0
16.0
or
15
26
.firstname salary
Rachel 32000
Peter 28000
count(distinct designation)
4
designation, sum(salary)
Manager 215000
sum(benefits)
6500
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)
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
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
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
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
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
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)
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
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');
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
24{"Rohan":67,"Ahasham":78,"naman":89,"pranav":79}
67
145
234
313
sum of values of dictionaries 313
or
15
26 i)Event NumPerformers
Engagement 12
Wedding 15
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
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
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');
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
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
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
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
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")
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
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
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
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
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
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
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
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
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
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)
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
21
a) prOgRaMmIn
b) 11
22
Data Definition Language affect structure of table
Create,Alter
Data Manipulation affects records in a table
Insert, Delete
24
Hub is a centralised distribution node
to connect all computers in a network
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
=====================================================
i
City
------
Delhi
Mumbai
Bangalore
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
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()
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)
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
24 kVS^NISHANT^3134
i) 0:0 iv)0:3
26 Max(Price) Min(QTY_Store)
15000 100
QUARTER SUM(QTY SOLD)
1 49
2 19
3 12
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
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%';
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
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
24 cbse#3134 #eXAMS
or
57
{(1,2,3):12,(4,5,6):20,(1,2):25}
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
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)
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()
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
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
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
Q31
a)
J
\
S_H
/ Star topology
A Optical Fiber
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
==
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
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()
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
15 Absence of a value
16 % and _
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;
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)
26 connect() creates a connection object to establish an unique session with the database
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
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
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']
[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
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...")
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
=============================================================================