QB For Final Revision - CS - XII - 2021 Part-2
QB For Final Revision - CS - XII - 2021 Part-2
2. What will be the content of file abc.txt after execution of the following code?
def f1():
for i in range(10):
f=open("abc.txt",'w')
f.write(str(i))
f.close()
f1()
Differentiate between:
1. Import random and from random import random
2. import math and from math import sqrt
Writing code:
1. Write a function in Python which takes three numbers as parameters and returns the largest of
these three numbers. The function should not use in-built max() function.
2. Write a function in Python which takes a string as a parameter and returns the reversed string
without using slicing.
3. Write a function in Python which takes a string of comma separated words as parameter and
returns a comma separated string in which the words of given string are sorted. For example, if the
given string is "Maths,English,Physics,Chemistry", then the returned string should be:
"Chemistry,English,Maths,Physics".
15. Write function definition for TOWER() in PYTHON to read the content of a text file
WRITEUP.TXT, count the presence of word TOWER and display the number of occurrences of
this word. (CBSE-Outside Delhi 2015)
Note :
‐ The word TOWER should be an independent word
‐ Ignore type cases (i.e. lower/upper case)
Example:
If the content of the file WRITEUP.TXT is as follows:
16. Write the function definition for WORD4CHAR() in PYTHON to read the content of a text file
FUN.TXT, and display all those words, which have four characters in it.
(CBSE- Delhi 2016)
Example:
If the content of the file Fun.TXT is as follows:
When I was a small child, I used to play in the
garden with my grand mom. Those days were amazingly
funful and I remember all the moments of that time
18. Write a function in Python to copy the contents of a text file into another text file. The names of
the files should be input from the user.
19. Write a function in Python which accepts two text file names as parameters. The function should
copy the contents of first file into the second file in such a way that all multiple consecutive
spaces are replaced by a single space. For example, if the first file contains:
Self conquest is the
greatest victory .
then after the function execution, second file should contain:
Self conquest is the
greatest victory .
20. Write a function in Python to input a multi-line string from the user and write this string into a file
named ‘Story.txt’. Assume that the file has to be created.
21. Write a function to display the last line of a text file. The name of the text file is passed as an
argument to the function.
22. Write a function which takes two file names as parameters. The function should read the first
file (a text file), and stores the index of this file in the second file (a binary file). The index should
tell the line numbers in which each of the words appear in the first file. If a word appears more
than once, the index should contain all the line numbers containing the word.
23. Write a Python function to read and display a text file 'BOOKS.TXT'. At the end display number
of lowercase characters, uppercase characters, and digits present in the text file.
24. Write a Python function to display the size of a text file after removing all the white spaces
(blanks, tabs, and EOL characters).
4. Write a function in PYTHON to search for a BookNo from a binary file “BOOK.DAT”, assuming
the binary file is containing the records of the following type:
{"BookNo":value, "Book_name":value}
Assume that BookNo is an integer.
5. Assuming that a binary file VINTAGE.DAT contains records of the following type, write a
function in PYTHON to read the data VINTAGE.DAT and display those vintage vehicles,
which are priced between 200000 and 250000. (CBSE 2012)
[VNO, VDesc, price]
6. Write a function in PYTHON to search for a laptop from a binary file “LAPTOP.DAT” containing
the records of following type. The user should enter the model number and the function should
display the details of the laptop. (CBSE 2011)
[ModelNo, RAM, HDD, Details]
where ModelNo, RAM, HDD are integers, and Details is a string.
7. Write a function in PYTHON to search for the details (Number and Calls) of those mobile
phones which have more than 1000 calls from a binary file “mobile.dat”. Assuming that this
binary file contains records of the following type:
(Number,calls)
8. Write a function in PYTHON to read the records from binary file GAMES.DAT and display the
details of those games, which are meant for children of AgeRange “8 to 13”. Assume that the
file GAMES.DAT contains records of the following type: (CBSE 2013)
[GameCode, GameName, AgeRange];
9. Write a function in PYTHON to read each record of a binary file ITEMS.DAT, find and display
those items which costs less than 2500. Assume that the file ITEMS.DAT is created with the
help of objects of the following type: (CBSE-Delhi 2015)
{"ID":string, "GIFT":string, "Cost":integer};
10. Write a definition for function BUMPER() in PYTHON to read each object of a binary file
GIFTS.DAT, find and display details of those gifts, which have remarks as “ON DISCOUNT”.
Assume that the file GIFTS.DAT is created with the help of lists of following type:
(ID, Gift, Remarks, Price)
(CBSE- Delhi 2016)
Stacks
1. Write functions stackpush(nameStack) to insert a new name and stackpop(nameStack) to
delete a name from a stack implemented using a list. The list is passed as an argument to
these functions.
2. Each element of a stack ITEM (a list) is a list containing two elements BNo (integer), and
Description (String). Write functions to push an element in the stack and to pop an element
from the stack. The popped element should be returned by the function. If the stack is empty,
the pop function should return None.
Assuming standard definitions of functions PUSH() and POP(), redraw the stack after
performing the following set of operations:
POP(S)
POP(S)
PUSH(S,8)
PUSH(S,3)
POP(S)
(i) POP() (ii) PUSH('Black') (iii) PUSH('Pink') (iv) POP() (v) PUSH('Green')
(iii) Give a suitable example of a table with sample data and illustrate Primary and Alternate keys in it.
(iv) Observe the following table carefully and write the names of the most appropriate columns, which
can be considered as (i) candidate keys and (ii) primary key. (CBSE-Delhi 2015)
Id Product Qty Price Transaction
Date
101 Plastic Folder 12" 100 3400 2014-12-14
104 Pen Stand Standard 200 4500 2015-01-31
105 Stapler Medium 250 1200 2015-02-28
109 Punching Machine Big 200 1400 2015-03-12
103 Stapler Mini 100 1500 2015-02-02
(v) Observe the following table carefully and write the names of the most appropriate columns, which
can be considered as (i) candidate keys and (ii) primary key. (CBSE-Outside Delhi 2015)
(vi) Observe the following STUDENTS and EVENTS tables carefully and write the name of the RDBMS
operation which will be used to produce the output as shown in LIST. Also, find the Degree and
Cardinality of the LIST. (CBSE- Delhi 2016)
STUDENTS EVENTS
No Name EVENTCODE EVENTNAME
1 Tara mani 1001 Programming
2 Jaya Sarkar 1002 IT Quiz
3 Tarini Trikha
LIST
NO NAME EVENTCODE EVENTNAME
1 Tara mani 1001 Programming
1 Tara mani 1002 IT Quiz
2 Jaya Sarkar 1001 Programming
2 Jaya Sarkar 1002 IT Quiz
3 Tarini Trikha 1001 Programming
3 Tarini Trikha 1002 IT Quiz
(vii) Observe the following PARTICIPANTS and EVENTS tables carefully and write the name of the
RDBMS operation which will be used to produce the output as shown in RESULT. Also, find the
Degree and Cardinality of the RESULT. (CBSE- Outside Delhi 2016)
PARTICIPANTS EVENTS
PNo Name EVENTCODE EVENTNAME
1 Aruanabha Tariban 1001 IT Quiz
2 John Fedricks 1002 Group Debate
3 Kanti Desai
RESULT
PNO NAME EVENTCODE EVENTNAME
1 Aruanabha Tariban 1001 IT Quiz
1 Aruanabha Tariban 1002 Group Debate
2 John Fedricks 1001 IT Quiz
2 John Fedricks 1002 Group Debate
3 Kanti Desai 1001 IT Quiz
3 Kanti Desai 1002 Group Debate
(iv) Write SQL commands for (a) to (f) and write the outputs for (g) on the basis of tables
FURNITURE and ARRIVALS:
ARRIVALS
NO ITEMNAME TYPE DATEOFSTOCK PRICE DISCOUNT
1 Wood Comfort Double Bed 23/03/03 25000 25
2 Old Fox Sofa 20/02/03 17000 20
3 Micky Baby cot 21/02/03 7500 15
a) To show all information about the Baby cots from the FURNITURE table.
b) To list the ITEMNAME which are priced at more than 15000 from the FURNITURE table.
c) To list ITEMNAME and TYPE of those items, in which date of stock is before 22/01/02
from the FURNITURE table in descending of ITEMNAME.
d) To display ITEMNAME and DATEOFSTOCK of those items, in which the discount
percentage is more than 25 from FURNITURE table.
e) To count the number of items, whose TYPE is "Sofa" from FURNITURE table.
f) To insert a new row in the ARRIVALS table with the following data:
14,“Valvet touch”, "Double bed", {25/03/03}, 25000,30
g) Give the output of following SQL stateme
Note: Outputs of the above mentioned queries should be based on original data
given in both the tables i.e., without considering the insertion done in (f) part of
this question.
(i) Select COUNT(distinct TYPE) from FURNITURE;
(ii) Select MAX(DISCOUNT) from FURNITURE,ARRIVALS;
(iii) Select AVG(DISCOUNT) from FURNITURE where TYPE="Baby cot";
(iv) Select SUM(Price) from FURNITURE where DATEOFSTOCK<{12/02/02};
(v) Consider the following tables GAMES and PLAYER. Write SQL commands for the statements
(a) to (d) and give outputs for SQL queries (E1) to (E4)
GAMES
GCode GameName Number PrizeMoney ScheduleDate
101 Carom Board 2 5000 23-Jan-2004
102 Badminton 2 12000 12-Dec-2003
103 Table Tennis 4 8000 14-Feb-2004
105 Chess 2 9000 01-Jan-2004
108 Lawn Tennis 4 25000 19-Mar-2004
PLAYER
PCode Name Gcode
1 Nabi Ahmad 101
2 Ravi Sahai 108
3 Jatin 101
4 Nazneen 103
TRADERS
TCode TName CITY
T01 ELECTRONIC SALES MUMBAI
T03 BUSY STORE CORP DELHI
T02 DISP HOUSE INC CHENNAI
a) To display the details of all the items in the ascending order of item names (i.e.
INAME).
b) To display item name and price of all those items, whose price is in range of
10000 and 22000 (both values inclusive).
c) To display the number of items, which are traded by each trader. The expected
output of this query should be:
T01 2
T02 2
T03 1
d) To display the price, item name and quantity (i.e. qty) of those items which
have quantity more than 150.
e) To display the names of those traders, who are either from DELHI or from
MUMBAI.
f) To display the names of the companies and the names of the items in descending
order of company names.
g1 ) SELECT MAX(PRICE), MIN(PRICE) FROM ITEMS;
g2 ) SELECT PRICE*QTY AMOUNT FROM ITEMS WHERE CODE-1004;
g3 ) SELECT DISTINCT TCODE FROM ITEMS;
g4 ) SELECT INAME, TNAME FROM ITEMS I, TRADERS T WHERE I.TCODE=T.TCODE
AND QTY<100;
Table: WORKER
WNO NAME DOJ DOB GENDER DCODE
1001 George K 2013-09-02 1991-09-01 MALE D01
1002 Ryma Sen 2012-12-11 1990-12-15 FEMALE D03
1003 Mohitesh 2013-02-03 1987-09-04 MALE D05
1007 Anil Jha 2014-01-17 1984-10-19 MALE D04
1004 Manila Sahai 2012-12-09 1986-11-14 FEMALE D01
1005 R SAHAY 2013-11-18 1987-03-31 MALE D02
1006 Jaya Priya 2014-06-09 1985-06-23 FEMALE D05
Note: DOJ refers to date of joining and DOB refers to date of Birth of workers.
(xi) Consider the following DEPT and EMPLOYEE tables. Write SQL queries for (i) to (iv) and
find outputs for SQL queries (v) to (viii). (CBSE-Outside Delhi 2015)
Table: DEPT
DCODE DEPARTMENT LOCATION
D01 INFRASTRUCTURE DELHI
D02 MARKETING DELHI
D03 MEDIA MUMBAI
D05 FINANCE KOLKATA
D04 HUMAN RESOURCE MUMBAI
Table: EMPLOYEE
ENO NAME DOJ DOB GENDER DCODE
1001 George K 20130902 19910901 MALE D01
1002 Ryma Sen 20121211 19901215 FEMALE D03
1003 Mohitesh 20130203 19870904 MALE D05
1007 Anil Jha 20140117 19841019 MALE D04
1004 Manila Sahai 20121209 19861114 FEMALE D01
1005 R SAHAY 20131118 19870331 MALE D02
1006 Jaya Priya 20140609 19850623 FEMALE D05
Note: DOJ refers to date of joining and DOB refers to date of Birth of employees.
(i) To display Eno, Name, Gender from the table EMPLOYEE in ascending order of Eno.
(ii) To display the Name of all the MALE employees from the table EMPLOYEE.
(iii) To display the Eno and Name of those employees from the table EMPLOYEE who
are born between '1987‐01‐01' and '1991‐12‐01'.
(iv) To count and display FEMALE employees who have joined after '1986‐01‐01'.
(v) SELECT COUNT(*),DCODE FROM EMPLOYEE
GROUP BY DCODE HAVING COUNT(*)>1;
(vi) SELECT DISTINCT DEPARTMENT FROM DEPT;
(vii) SELECT NAME, DEPARTMENT FROM EMPLOYEE E, DEPT
D WHERE E.DCODE=D.DCODE AND EN0<1003;
(viii) SELECT MAX(DOJ), MIN(DOB) FROM EMPLOYEE;
(xii) Write SQL queries for (i) to (iv) and find outputs for SQL queries (v) to (viii), which are based on
the tables. (CBSE- Delhi 2016)
Table: VEHICLE
Code VTYPE PERKM
101 VOLVO BUS 160
102 AC DELUXE BUS 150
103 ORDINARY BUS 90
105 SUV 40
104 CAR 20
Note:
• PERKM is Freight Charges per kilometer
• VTYPE is Vehicle Type
Note :
• NO is Traveller Number
• KM is Kilometer travelled
• NOP is number of travellers travelled in vehicle
• TDATE is Travel Date
(i) To display NO, NAME, TDATE from the table TRAVEL in descending order of NO.
(ii) To display the NAME of all the travellers from the table TRAVEL who are travelling
by vehicle with code 101 or 102.
(iii) To display the NO and NAME of those travellers from the table TRAVEL who
travelled between ‘2015-12-31’ and ‘2015-04-01’.
(iv) To display all the details from table TRAVEL for the travellers, who have travelled
distance more than 100 KM in ascending order of NOP.
(v) SELECT COUNT (*), CODE FROM TRAVEL GROUP BY CODE HAVING
COUNT(*)>1;
(vi) SELECT DISTINCT CODE FROM TRAVEL;
(vii) SELECT A.CODE,NAME,VTYPE FROM TRAVEL A,VEHICLE B WHERE
A.CODE=B.CODE AND KM<90;
(viii) SELECT NAME,KM*PERKM FROM TRAVEL A, VEHICLE B WHERE
A.CODE=B.CODE AND A.CODE=‘105’;
(xiii) Write SQL queries for (i) to (iv) and find outputs for SQL queries (v) to (viii), which are based on
the tables. (CBSE- Outside Delhi 2016)
Table: VEHICLE
VCODE VEHICLETYPE PERKM
V01 VOLVO BUS 150
V02 AC DELUXE BUS 125
V03 ORDINARY BUS 80
V05 SUV 30
V04 CAR 18
Note:
• PERKM is Freight Charges per kilometer
Table: TRAVEL
CNO CNAME TRAVELDATE KM VCODE NOP
101 K.Niwal 2015-12-13 200 V01 32
103 Fredrick Sym 2016-03-21 120 V03 45
105 Hitesh Jain 2016-04-23 450 V02 42
102 Ravi anish 2016-01-13 80 V02 40
107 John Malina 2015-02-10 65 V04 2
104 Sahanubhuti 2016-01-28 90 V05 4
106 Ramesh jaya 2016-04-06 100 V01 25
Note :
• KM is Kilometer travelled
• NOP is number of travellers travelled in vehicle
• TDATE is Travel Date
(i) To display CNO, CNAME, TRAVELDATE from the table TRAVEL in descending
order of CNO.
40. Which of the following crime(s) is/are covered under cybercrime? (CBSE 2013)
(i) Stealing brand new hard disk from a shop
(ii) Getting into unknown person’s social networking account and start messaging on his
behalf.
(iii) Copying some important data from a computer without taking permission from the owner
of the data.
(ii) Granuda Consultants are setting up a secured network for their office campus at Faridabad for their
day to day office and web based activities. They are planning to have connectivity between 3
buildings and the head office situated in Kolkata. Answer the questions (a) to (d) after going through
the building positions in the campus and other details, which are given below: (CBSE 2012)
Number of computers:
Building “RAVI” 25
Building “JAMUNA” 150
Building “GANGA” 51
Head Office 10
a) Suggest the most suitable place (i.e. block) to house the server of this organization. Also give
a reason to justify your suggested location.
b) Suggest a cable layout of connections between the buildings inside the campus.
c) Suggest the placement of the following devices with justification:
(i) Switch
(ii) Repeater
d) The organization is planning to provide a high speed link with its head office situated in
KOLKATA using a wired connection. Which of the following cable will be most suitable for this
job?
(i) Optical Fiber
(ii) Co-axial cable
(iii) Ethernet cable
(iii) Expertia Professional Global (EPG) is an online corporate training provider company for IT related
courses. The company is setting up their new campus in Mumbai. You as a network expert have
to study the physical locations of various buildings and the number of computers to be installed. In
the planning phase, provide the best possible answers for the queries (a) to (d) raised by them.
(CBSE 2013)
a) Suggest the most appropriate building, where EPG should plan to install the server.
b) Suggest the most appropriate building to building cable layout to connect all three buildings
for efficient communication.
c) Which type of network out of the following is formed by connecting the computers of these
three buildings?
LAN, MAN, WAN
d) Which wireless channel out of the following should be opted by EPG to connect to students
of all over the world?
Infrared, Microwave, Satellite
(iv) Trine Tech Corporation (TTC) is a professional consultancy company. The company is planning to
set up their new offices in India with its hub at Hyderabad. As a network adviser, you have to
understand their requirement and suggest them the best available solutions. Their queries are
mentioned (a) to (d) below. (CBSE 2014)
(v) Perfect Edu Services Ltd. is an educational organization. It is planning to setup its India campus at
Chennai with its head office at Delhi. The Chennai campus has 4 main buildings – ADMIN,
ENGINEERING, BUSINESS and MEDIA (CBSE 2015)
(vi) Xcelencia Edu Services Ltd. is an educational organization. It is planning to set up its India campus
at Hyderabad with its head office at Delhi. The Hyderabad campus has 4 main buildings:
ADMIN, SCIENCE, BUSINESS and MEDIA. (CBSE-Outside Delhi 2015)
You as a network expert have to suggest the best network related solutions for their problems
raised in (a) to (d), keeping in mind the distances between the buildings and other given
parameters.
a) Suggest the most appropriate location of the server inside the HYDERABAD campus (out
of the 4 buildings), to get the best connectivity for maximum no. of computers. Justify your
answer.
b) Suggest and draw the cable layout to efficiently connect various buildings 'within the
HYDERABAD campus for connecting the computers.
c) Which hardware device will you suggest to be procured by the company to be installed to
protect and control the internet uses within the campus?
d) Which of the following will you suggest to establish the online face‐to‐face communication
between the people in the Admin Office of HYDERABAD campus and DELHI Head Office?
(a) E‐mail (b) Text Chat (c) Video Conferencing (d) Cable TV
(vii) Uplifting Skills Hub India is a knowledge and skill community which has an aim to uplift the standard
of knowledge and skills in the society. It is planning to setup its training centers in multiple towns
and villages pan India with its head offices in the nearest cities. They have created a model of their
network with a city, a town and 3 villages as follows:
As a network consultant, you have to suggest the best network related solutions for their
issues/problems raised in (a) to (d) keeping in mind the distances between various locations and
other given parameters.
Shortest distances between various locations:
VILLAGE 1 to B_TOWN 2 KM
VILLAGE 2 to B_TOWN 1.0 KM
VILLAGE 3 to B_TOWN 1.5 KM
VILLAGE 1 to VILLAGE 2 3.5 KM
VILLAGE 1 to VILLAGE 3 4.5 KM
VILLAGE 2 to VILLAGE 3 2.5 KM
A_CITY Head Office to B_HUB 25 KM
Note :
• In Villages, there are community centers, in which one room has been given as training
center to this organization to install computers.
• The organization has got financial support from the government and top IT companies.
a) Suggest the most appropriate location of the SERVER in the B_HUB (out of the 4
locations), to get the best and effective connectivity. Justify your answer.
b) Suggest the best wired medium and draw the cable layout (location to location) to
efficiently connect various locations within the B_HUB.
c) Which hardware device will you suggest to connect all the computers within each
location of B_HUB?
d) Which service/protocol will be most helpful to conduct live interactions of Experts
from Head Office and people at all locations of B_HUB?
(viii) Intelligent Hub India is a knowledge community aimed to uplift the standard of skills and knowledge
in the society. It is planning to setup its training centers in multiple towns and villages pan India
with its head offices in the nearest cities. They have created a model of their network with a city, a
town and 3 villages as follows.
As a network consultant, you have to suggest the best network related solutions for their
issues/problems raised in (a) to (d), keeping in mind the distances between various locations and
other given parameters.
Note:
• In Villages, there are community centers, in which one room has been given as training center to
this organization to install computers.
• The organization has got financial support from the government and top IT companies.
a) Suggest the most appropriate location of the SERVER in the YHUB (out of the 4 locations), to
get the best and effective connectivity. Justify your answer.
b) Suggest the best wired medium and draw the cable layout (location to location) to efficiently
connect various locations within the YHUB.
c) Which hardware device will you suggest to connect all the computers within each location of
YHUB?
d) Which service/protocol will be most helpful to conduct live interactions of Experts from Head
Office and people at YHUB locations?
9. Which of the following crime(s) is/are covered under cybercrime? (CBSE 2013)
(iv) Stealing brand new hard disk from a shop
(v) Getting into unknown person’s social networking account and start messaging on his
behalf.
(vi) Copying some important data from a computer without taking permission from the owner
of the data.
ANSWERS
Descriptive Questions:
1. A function is a named group of statements which get executed when the function is invoked.
2.
Actual Parameters Formal Parameter
Parameter used in function call. Parameter used in function definition.
Can be an identifier, a literal, or any other valid Has to be an identifier only.
expression.
Example:
def func(a,b):
print(a,b)
r=1
func(3,r*2)
In the above code, 3 and r*2 in the function call are actual parameters, whereas a and b in
the function definition are formal parameters.
3.
Value Parameter Reference Parameter
It is a copy of the corresponding actual It is an alias of the corresponding reference
parameter. parameter.
Any change in a value parameter does not Any change in a reference parameter is
affect the corresponding actual parameter. reflected on the corresponding actual
parameter too.
All immutable data objects are accepted as All mutable data objects are accepted as
value parameters in a function. reference parameters in a function.
Example:
def func(a,b):
a[b]+=1
b+=1
arr=[1,2,3,4]
n=2
func(arr,n)
print(arr,n)
19. Writing data in the file, Reading data from the file.
20. It is a small memory space allocated to a file object. All the transfer of data between the program and
the file (on secondary storage device) happens through buffer only. Each file object is allocated its own
separate buffer.
21. A file can be opened using the open() function.
22.
File opening If the file already exists If the file does not exist
mode
‘r’ File is opened in read mode. FileNotFoundError is raised.
‘r+’ File is opened in read-write mode FileNotFoundError is raised.
with file pointer at 0.
‘w’ File contents are deleted and file is File is created and opened in write mode.
opened in write mode.
23.
Write mode Append mode
Data can be written anywhere in the file. Data can be written only at the end of the
existing data in the file.
File pointer can be adjusted using seek() File pointer cannot be adjusted.
Already existing data, if any, is deleted from the Already existing data, if any, is not deleted from
file. the file.
2. 9
Writing code:
1. def high(a,b,c):
if a>=b and a>=c:
return a
if b>=c and b>=a:
return b
if c>=a and c>=b:
return c
2. def rev_str(s):
s1=''
for ch in s:
s1=ch+s1
return s1
3. def sort_words(s):
s=s.split(',')
s.sort()
s=','.join(s)
return s
7. def last_three():
f=open("story.txt")
data=f.read()
data=data.strip()
print(data[-3:])
f.close()
8. def copy():
f1=open("FAIPS.txt")
f2=open("DPS.txt",'w')
data=f1.read()
for word in data:
if word[0].isupper():
f2.write(word+" ")
f1.close()
f2.close()
9. def show(n):
f=open("MIRA.TXT")
data=f.read()
f.close()
if len(data)<n:
print("Inavid n")
else: print(data[n-1])
def stackpop(stack):
if nameStack==[]:
return None
else:
return nameStack.pop()
2. def stackpush(stack):
bn=int(input("Enter BNo: "))
Desc=input("Enter Description: ")
ele=[bn,Desc]
stack.append(ele)
def stackpop(stack):
if stack==[]:
return None
else:
return stack.pop()
3. def PUSH(TEXTBOOKS):
isbn=int(input("Enter ISBN: "))
title = input("Enter title: ")
price=float(input("Enter price: "))
ele={'ISBN':isbn,'TITLE':title,'PRICE':price}
TEXTBOOKS.append(ele)
def POP(TEXTBOOKS):
if TEXTBOOKS==[]:
return None
else:
return TEXTBOOKS.pop()
4.
5.
(iii) A table may have more than one such attribute/group of attributes that identify a row/tuple
uniquely. All such attribute(s)/group(s) are known as Candidate keys. Out of the candidate keys,
one is selected as primary key and the other keys are known an alternate keys.
Example:
Relation: Stock
Ino Item Qty Price
I01 Pen 560 2
I02 Pencil 600 1
I03 CD 200 3
In this relation Ino and Item are Candidate keys. If Ino is selected as the primary key, then Item
will be the alternate key, and vice-versa.
(v)
a) SELECT GAMENAME, GCODE FROM GAMES;
b) SELECT * FROM GAMES WHERE PRZEMONEY > 7000;
c) SELECT * FROM GAMES ORDER BY SCHEDULEDATE;
d) SELECT NUMBER, SUM(PRIZEMONEY) FROM GAMES GROUP BY NUMBER;
(e1) 2
4
(e2) MAX(ScheduleDate) MIN(ScheduleDate)
----------------- -----------------
19-Mar-2004 12-Dec-2003
(e3) 59000
(e4) 101
108
103
(vi)
(a)
(i) SELECT * FROM WORKER ORDER BY DOB DESC;
(ii) SELECT NAME, DESIG FROM WORKER WHERE PLEVEL IN (“P001”, “P002”);
(iii) SELECT * FROM WORKER WHERE DOB BETWEEN “19-JAN-1984” AND “18-JAN-
1987”;
(iv) INSERT INTO WORKER VALUES
(19, ‘Daya kishore’, ‘Operator’, ‘P003’, ’19-Jun-2008’, ’11-Jul-
1984’);
(b)
(i)
COUNT(PLEVEL) PLEVEL
1 P001
2 P002
2 P003
(ii)
MAX(DOB)) MIN(DOJ)
12-Jul-1987 13-Sep-2004
(iii)
Name Pay
Radhey Shyam 26000
Chander Nath 12000
(iv)
PLEVEL PAY+ALLOWANCE
P003 18000
(vii)
(a)
1) SELECT VehicleName FROM CARHUB WHERE Color = ‘WHITE’;
2) SELECT VehicleName, Make, Capacity FROM CARHUB ORDER BY CAPACITY;
3) SELECT MAX(Charges) FROM CARHUB;
4) SELECT CName, VehicleName, FROM CUSTOMER, CARHUB
WHERE CUSTOMER.Vcode = CARHUB.Vcode;
(b)
1)
COUNT(DISTINCT Make)
4
2)
MAX(Charges) MIN(Charges)
35 12
(viii)
a) SELECT * FROM ITEMS ORDER BY INAME;
b) SELECT INAME, PRICE FROM ITEMS WHERE PRICE BETWEEN 10000 AND 22000;
c) SELECT TCODE, COUNT(*) FROM ITEMS GROUP BY TCODE;
d) SELECT PRICE, INAME, QTY FROM ITEMS WHERE QTY > 150;
e) SELECT INAME FROM TRADERS WHERE CITY IN (‘DELHI’, ‘MUMBAI’);
f) SELECT COMPANY, INAME FROM ITEMS ORDER BY COMPANY DESC;
g1 )
MAX(PRICE) MIN(PRICE)
38000 1200
g2 )
AMOUNT
1075000
g3 )
DISTINCT TCODE
T01
T02
T03
g4 )
INAME TNAME
LED SCREEN 40 DISP HOUSE INC
CAR GPS SYSTEM ELECTRONIC SALES
(ix)
(a)
1) SELECT IName, price from Item ORDER BY Price;
2) SELECT SNo, SName FROM Store WHERE Area=’CP’;
3) SELECT IName, MIN(Price), MAX(Price) FROM Item GROUP BY IName;
4) SELECT IName, Price, SName FROM Item, Store Where Item.SNo =
Store.SNo;
(b)
1)
DISTINCT INAME
Hard disk
LCD
Mother Board
2)
Area Count(*)
CP 2
GK II 1
Nehru Place 2
3)
COUNT(DISTINCT AREA)
3
4)
INAME DISCOUNT
Keyboard 25
Mother Board 650
Hard Disk 225
(v)
COUNT(*) DCODE
2 D01
2 D05
(vi)
Department
MEDIA
MARKETING
INFRASTRUCTURE
FINANCE
HUMAN RESOURCE
(vii)
NAME DEPARTMENT CITY
George K MEDIA DELHI
Ryma Sen INFRASTRUCTURE MUMBAI
(viii)
MAX(DOJ) MIN(DOB)
2014-06-09 1984-10-19
(xi)
(i) SELECT Eno,Name,Gender FROM Employee ORDER BY Eno;
(ii) SELECT Name FROM Employee WHERE Gender=’MALE’;
(iii) SELECT Eno,Name FROM Employee
WHERE DOB BETWEEN ‘19870101’ AND ‘19911201’;
OR
SELECT Eno,Name FROM Employee
WHERE DOB >=‘19870101’ AND DOB <=‘19911201’;
OR
SELECT Eno,Name FROM Employee
WHERE DOB >‘19870101’ AND DOB <‘19911201’;
(xii)
(i) SELECT NO, NAME, TDATE FROM TRAVEL ORDER BY NO DESC;
(ii) SELECT NAME FROM TRAVEL
WHERE CODE=101 OR CODE=102;
(iii) SELECT NO, NAME from TRAVEL
WHERE TDATE BETWEEN ‘2015-04-01’ AND ‘2015-12-31’;
(iv) SELECT * FROM TRAVEL WHERE KM > 100 ORDER BY NOP;
(xiii)
(i) SELECT CNO, CNAME, TRAVELDATE FROM TRAVEL ORDER BY CNO DESC;
(vi)
DISTINCT VCODE
V01
V02
V03
V04
V05
17. FTP
18. Speed ‐
• Faster web browsing
• Faster file transfer
Service ‐
• Better video clarity
• Better security
19. Attenuation: Reduction in the strength of a signal during transmission. It happens when a signal travels
long distances over a network.
20. IPv4 is a 32 bit address, whereas IPv6 is a 128 bit address. Examples:
IPv4: 192.168.72.54 IPv6: 2001:0cb8:85a3:0000:0000:8c2e:0370:7a34
21.
Physical Address Logical Address
It is the MAC address of the NIC of the device. It is the IP address of the device.
It is used by switches for communication within a It is used by routers for communication
network. between networks.
22. Guided media refers to cables such as Twisted Pair cables, Coaxial cables, and Optical Fiber cables.
Unguided media refers to waves such as radio waves, micro waves, and infrared rays.
23. (i) Remote Login: Using remote login, a user is able to access a computer or a network remotely through a
network connection. Remote login enables users to access the systems they need when they are not
physically able to connect directly.
(ii) Remote Desktop: Remote desktop is a program or an operating system feature that allows a user to
connect to a computer in another location, see that computer's desktop and interact with it as if it were
local.
24. Application Layer is the top most Layer of a computer network, and is implemented in end nodes e.g.
computers. Some protocols of Application Layer are FTP(File Transfer Protocol), HTTP (Hyper Text Transfer
Protocol) , SMTP (Simple Mail Transfer Protocol) etc.
25. (i) Wi-fi is a technology that is used for short distance wireless communication. Wi-Fi uses radio waves of
frequency 2.4GHz and 5GHz.
(ii) Access Point: It is a device in a wireless network that broadcasts a wireless signal that devices can detect
and "tune" into.
26. DNS (domain name system): It is a system of remote servers used to convert domain names to their
corresponding IP addresses.
27.
Bus Topology Star Topology
Slower as compared to Star topology of network Expensive as compared to Bus
topology
Breakage of wire at any point disturbs the entire Long wire length is required.
network.
c) Switch
d) WAN as the given distance is more than the range of LAN and MAN.
(ii)
a) Building “Jamuna” as it contains the maximum number of computers.
b)
c)
(i) Switch is needed to be placed in each building to interconnect the computers within
that building.
(ii) Repeater is needed to be placed between “Jamuna” and “Ravi” as the distance is
more than 90m.
(iii)
a) Faculty Studio as it contains the maximum number of computers.
b)
c) LAN
d) Satellite
(iv)
a) Finance
b)
c) Satellite Link
d) Switch
(v)
a) ADMIN (due to maximum number of computers)
OR
MEDIA (due to shorter distance from the other buildings)
c) Firewall OR Router
d) Video Conferencing
(vi)
a) ADMIN (due to maximum number of computers)
OR
ARTS (due to shorter distance from the other buildings)
c) Firewall OR Router
d) Video Conferencing
(vii)
a) B_TOWN. Since it has the maximum number of computers and is closest to all other
locations.
b)
c) Switch OR Hub
d) Videoconferencing OR VoIP OR any other correct service/protocol
(viii)
a) B_TOWN. Since it has the maximum number of computers and is closest to all other
locations
b)
c) Switch OR Hub
d) Videoconferencing OR VoIP OR any other correct service/protocol