CS Answers - 2019-20 - SET2
CS Answers - 2019-20 - SET2
GENERAL INSTRUCTIONS
PART A
Q1 a) Identify and write the name of the module to which the following functions belong: 1
(i) uniform()
(ii) fabs()
d) Rewrite the following code in python after removing all syntax error(s). Underline each 2
correction done in the code.
def chksum:
x= input("Enter a number")
if (x%2 = 0):
for i range(2*x):
print(i)
loop else:
print("#")
Page 1 of 13
else:
print("#")
Ans. 16 6
4 3
24 6
g) Observe the following program and find out, which output(s) out of (i) to (iv) will be 2
expected from the program? What will be the minimum and the maximum value
assigned to the variable alter?
import random
Ar= [10, 7]
alter = random.randint(0,2) + 10;
for C in range(0,2):
print(Ar[C] + alter, end = " # ")
Page 2 of 13
Ans: i) , ii) and iv)
d) A text file “MyFile.txt” contains alphanumeric text. Write a program that reads this text file 2
and prints only the numbers or digits from the file.
Ans :
F = open("MyFile.txt ", "r")
for line in F:
words = line.split()
for i in words:
for letter in i:
if(letter.isdigit()):
print(letter)
f) Write a recursive function that computes the series; 1+4+9+ …n 2 where the value of 3
the n is given by the user
Page 3 of 13
if num == 1:
return 1
else:
return(num * num + compute(num - 1))
# main function
n = int(input("Enter the number : "))
res = compute(n)
print("The sum of the series is :",res)
OR
Write a python function to search for a string in the given list using binary search
method. Function should receive the list and a string to be searched as arguments and
return index if the value is found -1 otherwise
Ans:
#Binary Search
def BS(l,ll,ul,s):
if ll > ul:
return -1
else:
m = (ll + ul)//2 #ll + (ul - ll) //2
if l[m] > s:
return BS(l,ll,m-1, s)
elif l[m] < s:
return BS(l, m+1, ul,s)
else:
return m
def main():
lst = eval(input("Enter the list :"))
se = eval(input("Enter the search element:"))
#lst.sort()
p = BS(lst,0,len(lst)-1,se)
if p < 0 :
print("Not found")
else:
print("Found at ", p)
main()
def isEmpty(stk):
if stk == []:
Page 4 of 13
return True
else:
return False
def Push(stk,item):
stk.append(item)
top = len(stk) - 1
def Pop(stk):
if isEmpty(stk):
print("Stack empty")
else:
top = len(stk) - 1
del stk[top]
def Display(stk):
if isEmpty(stk):
print("Stack empty")
else:
top = len(stk) - 1
print(stk[top])
for a in range(top-1,-1,-1):
print(stk[a])
# __main__
Stack = []
top = None
while True:
print("STACK OPERATIONS :")
print("1. PUSH")
print("2. POP")
print("3. EXIT")
ch = int(input("Enter your choice (1 - 5) :"))
if ch == 1:
pin = int(input("Enter city pincode to be inserted :"))
cname = input("Enter city name to be inserted :")
item = [pin,cname]
Push(Stack,item)
Display(Stack)
elif ch == 2:
Pop(Stack)
Display(Stack)
elif ch == 3:
break
else:
print("Invalid Choice")
OR
Page 5 of 13
Ans: def Enque(queue,item):
queue.append(item)
def Deque(queue):
if (queue==[]):
print("Queue empty")
else:
print("Deleted element is: ",queue[0])
del queue[0]
#Calling function
que = []
cont = True
while cont == True:
print("Enter 1 to add new employee :")
print("Enter 2 to remove an employee :")
ch = int(input("Enter your choice :"))
if ch == 1:
print("For the new employee, enter details below:")
eId = int(input("Enter employee id :"))
eName = input("Enter employee name :")
ePhone = int(input("Enter employee's phone number :"))
ele = [eId,eName,ePhone]
Enque(que,ele)
else:
Deque(que)
print("The updated list is :", que)
c = input("Do you want to continue... (Y/N)? ")
if c.upper( ) == 'N':
cont = False
h) Give postfix form of the following expression showing in a tabular form the 2
changing status of the stack:
(A* B) - (C+ D) / E
Page 6 of 13
i) Write a code to create a pie chart for Rainfall = [180,220,140,150,110] for Zones 3
= ['East','West','North','South','Central']
i) Show North zone‟s value exploded
ii) Show % contribution for each zone
iii) The pie chart should be circular
Ans:
import matplotlib.pyplot as plt
Rainfall = [180,220,140,150,110]
Zones = ['East','West','North','South','Central']
plt.axis("equal")
plt.pie(Rainfall,labels = Zones, explode = [0,0,0.2,0,0], autopct = "%1.1f%%")
plt.show()
OR
PART B
Q3 a) ____________ is a device that connects dissimilar networks 1
b) Name the type of error occurs when two or more nonconsecutive bits in data got 1
changes from 0 to 1 or from 1 to 0
Page 7 of 13
d) Kabir wants to purchase a Book online and placed the order for that book using an 1
ecommerce website. Now, he is going to pay the amount for that book online using his
Mobile, he needs which of the following to complete the online transaction :
i) A bank account
ii) A Mobile connection/phone which is attached to above bank account,
iii) The mobile banking app of the above bank installed on that mobile
iv) Login credentials (UserId & Password) provided by the bank,
v) All of above
Ans: (v)
e) Write the expanded forms of the following abbreviated terms used in networking and 2
communications:
i) FTP
ii) WiFi
iii) IoT
iv) DNS
Ans:
i) FTP - File Transfer Protocol
ii) WiFi - Wireless Fidelity
iii) IoT - Internet of Things
iv) DNS - Domain Name System
Ans: PING command tests the connectivity between two hosts whereas TRACEROUT
command shows the number of hops and response time to connect to a remote system or
website.
Ans:
i) These are the clouds for use by multiple organizations (tenants) on a shared
basis and hosted and managed by a third-party service provider.
ii) Switches work similarly like Hubs but in a more efficient manner. It creates
connections dynamically and provides information only to the requesting port.
Switch is a device in a network which forwards packets in a network.
iii) A fiber optic cable consists of a bundle of glass threads, each of which is
capable of transmitting messages modulated onto light waves. Common types
of Fiber Optic Cables are single node and multi-node.
h) Rehaana Medicos Center has set up its new center in Dubai. It has four buildings as shown 4
in the diagram given below:
Page 8 of 13
Distances between various buildings are as follows:
Accounts to Research Lab 55 m
Accounts to Store 150m
Store to Packaging Unit 160 m
Packaging Unit to Research Lab 60 m
Accounts to Packaging Unit 125 m
Store to Research Lab 180 m
Number of computers:
Accounts 25
Research Lab 100
Store 15
Packaging Unit 60
As a network expert, provide the best possible answer for the following queries:
i) Suggest a cable layout of connections between the buildings.
ii) Suggest the most suitable place (i.e. buildings) to house the server of this
organization.
iii) Suggest the placement of the following device with justification:
a) Repeater b) Hub/Switch
iv) Suggest a system (hardware/software) to prevent unauthorized access
to or from the network.
Ans: i) Layout 1
OR
Layout 2
Page 9 of 13
ii) The most suitable place/ building to house the server of this organization would be
building Research Lab, as this building contains the maximum number of
computers. For layout1, since the cabling distance between Accounts to Store is
quite large, so a repeater would ideally be needed along their path to avoid loss of
signals during the course of data flow in this route. For layout2, since the cabling
distance between Store to Research Lab is quite large, so a repeater would ideally
be placed.
iii) In both the layouts, a Hub/Switch each would be needed in all the buildings to
interconnect the group of cables from the different computers in each building.
iv) Firewall
PART C
Q4 a) Observe the table „Club‟ given below: 1
If a new column contact_no has been added and three more members have joined the club
then how these changes will affect the degree and cardinality of the above given table.
Ans: No. NULL value specifies a legal empty value whereas 0 is a number having the
value Zero.
Ans:
i) DESCRIBE or DESC
ii) CurDate()
d) Mr. Mittal is using a table with following columns: Name, Class, StreamName 1
He needs to display names of students who have not been assigned any stream. He
Page 10 of 13
wrote the following command, which did not give the desired result.
SELECT Name, Class FROM Students WHERE StreamName = NULL;
Help Mr. Mittal to run the query by removing the error and write the correct query.
f) Write the commands to create a Django project “School” and two apps “Students” and 2
“Teachers”.
Table : Salary
StaffId Basic Allowance CommPer
1125 14000 1500 9
1263 25000 2800 6
236 13500 1400 5
321 12000 1500 5
366 26100 3100 12
Ans:
i) SELECT Name. Dept FROM Staff WHERE Experience >= 10;
ii) SELECT AVERAGE(Basic + Allowance) From Staff S1, Salary S2 WHERE
S1.StaffId = S2.StaffId;
iii) SELECT * FROM Staff WHERE Gender = „F‟ AND Dept = „Sales‟;
iv) UPDATE Staff SET Basic = 1.10 * Basic WHERE Name LIKE „N%‟;
Page 11 of 13
h) Consider the tables given in 4(g) and write the outputs for below queries: 3
i) SELECT Name FROM Staff WHERE Gender = „M‟ ORDER BY Name DESC;
ii) SELECT Dept, Count(StaffId) from Staff Group By Dept ;
iii) SELECT * FROM Salary WHERE CommPer BETWEEN 6 TO 12;
Ans :
v)
Name
Palak
Noopur
Nayana
vi)
Dept Count(StaffId)
Sales 3
Finance 2
Research 1
vii)
PART D
Q5 a) Standard security protocol that establishes encrypted links between a web server and 1
a browser is called _______________
Ans : Digital property is any information about you or created by you that exists in
digital form, either online or on an electronic storage device.
Intellectual Property is the creative creations of mind such as patents, literary and
creative arts, copyrights, trademarks etc.
Page 12 of 13
e) Arun opened his e-mail and found that his inbox was full of hundreds of unwanted mails. It 2
took him around two hours to delete these unwanted mails and find the relevant ones in his
inbox. What can Arun do to prevent this happening in future?
Ans: Prevention measure that Arun can implement are:
i) Download spam filtering tools and anti-virus software
ii) Make Use of Email Security Measures
iii) Unsubscribe to Unwanted Messages
iv) Never give out or post his email address publicly
v) Do not reply to spam messages
(Any two)
f) How can special needs of differently abled students be met while teaching 2
computers?
Ans: (Any two)
i) Schools must work towards making available the required teaching
aids/materials to fulfill special needs of students with disabilities.
ii) School must employ special needs teachers and should also train other teachers
as well about how to interact with students with special needs so as to help them
learn in a better inclusive way.
iii) There should be special budget allocated for buying the required material and
equipment to promote inclusive education and also for training the staff about
such needs.
iv) Schools must support the inclusive curriculum
Page 13 of 13