Set 1
Set 1
3. Which of the following is correct to retrieve any character at index 'i' in string 's'? [1]
a) s.__getitem__(i) b) s.getitem(i-1)
c)s.__getitem__(i-1) d) s.getitem(i)
value =50
def display(N):
global value
value = 25
if N%7==0:
value = value + N
else:
value =value - N
print(value, end="#")
display(20)
print(value)
a) 5#50# b) 50#50
c) 50#5 d) 50#30
Signals generated by an operating system to send it over phone line must be further [1]
converted into a/an
To read the next line of the file from a file object infi, we use (1
a) infi.read() b) infi.readlines()
c) infi.readline() d) infi.read(all)
Which of the following sublanguages of SQL is used to define the structure of the [1]
relation, deleting relations and relating schemas?
c) readchar( ) d) readall( )
a) None b) Null
c) 50 d)o
a)4 b)3
o)1 d)2
14. The process of converting a data type into another data type is known as [1]
a) expression b) type conversion
c) operator d) comparison
a) Both A and R are true and R is b) Both A and R are true but R is
the correct explanation of A. not the correct explanation of A.
18. Assertion (A): CSV stands for comma-separated values, which is defined as a simple [1]
file format that uses specific structuring to arrange tabular data.
Reason (R): The csv module is used to handle the CSV files to read/write and get
data from specified columns.
a) Both A and R are true and R is b) Both A and R are true but R is
the correct explanation of A. not the correct explanation of A.
Section B
19. Answer: [2]
(i) i. Whatis modulation? [1]
ii. Write one characteristic each for 2G and 3G mobile technologies. [1]
(i) OR
i. What are the basic methods of checking errors in the data being [2]
transmitted over networks?
20. Write Python code to create a table location with the following fields [2]
id id of the location
bidycode code of the building
room type of rooms
capacity capacity of the room
21. Rewrite the following code in python after removing all syntax error(s). [2]
Underline each correction done in the code.
30=To
for K in range(0,To)
IF k%4==0:
print (K * 4)
Else:
print (K + 3)
OR
What is the output of the following?
True = False
while True:
print(True)
break
(i) Which command is used to import mysql.connector package with an identifier? [1]
23. Differentiate between a logical error and syntax error. Also, give suitable examples of [2]
each in Python.
OR
As immutable types cannot be changed in place then the following code should raise an
error which modifies an int (an immutable type) variable. But it produces no error. Why?
A=22
A+=2
24. Consider a binary file Employee.dat containing details such as empno:ename:salary [2]
(separator ":'). Write a Python function to display details of those employees who
are earning between 20000 and 40000. (Both values inclusive)
OR
A text file(say an.txt) contains alphanumeric text. Write a program that reads this text
file and prints only the numbers or digits from the file.
25. Write a function that takes a positive integer and returns the one's position digit of [2]
the integer.
Section C
dic={a':1,'b':2,'c':3,'d" : 4}
print(dic)
if 'a' in dic:
del dic['a']
print(dic)
27. Write a method in Python to find and display the prime number between 2 to n. [3]
Pass n as an argument to the method.
OR
What are Tuples in a SQL Table? Write a suitable example with a SQL Table to illustrate
your answer.
29. A text file "Quotes.Txt" has the following data written in it : [3]
Living a life you can be proud of Doing you
Spending your time with people and activities that are important to you
Standing up for things that are right even when it's hard
Becoming the best version of you
Write a user defined function to display the total number of words present in the
file.
30. Write a function that takes a sorted list and a number as an argument. Search for 3]
the number in the sorted list using binary search.
Section D
31. Ayurveda Training Educational Institute is setting up its Centre in Hyderabad with [5]
three specialized departments for Orthopaedics, Neurology and Paediatrics along
with an administrative office in separate buildings. The physical distances between
these department buildings and the member of computers to be installed in these
departments and administrative offices are given as follows. You, as a network
expert have the shortest distances between various locations in meters:
Administrative office to Orthopaedics unit 55
Neurology unit to Administrative office 30
Paediatrics unit 40
Administrative office 140
Neurology unit 50
Orthopedics unit 80
i. Suggest the most suitable location for the main server of this institution to get
efficient connectivity.
ii. Suggest the cable layout for effective network connectivity of the building having
a server with all the other buildings.
iii. Suggest a device to be installed in each of these building for connecting
computers installed within the building out of the following:
* Gateway
e Modem
® Switch
iv. Suggest the topology of the network and network cable for efficiently connecting
in each of the building one of the following: Topologies: Bus Topology, Star
Topology, Network Cable: Single Pair Telephone Cable, Coaxial Cable, Ethernet
Cable.
32. Write SQL queries for (i) to (vii) on the basis of table ITEMS and TRADERS:
Table: ITEMS
ICODE |INAME QTY |PRICE |[COMPANY TCODE
Table: TRADERS
i. To display the details of all the items in ascending order of item names (i.e.,
INAME).
ii. To display item name and price of all those items, whose price is in the range of
10000 and 22000 (both values inclusive).
iii. To display the number of items, which are traded by each trader. The expected
output of this query should be:
TO012T7022T031
iv. To display the price, item name and quantity (i.e., qty) of those items which have
quantity more than 150.
v. To display the names of those traders, who are either from DELHI or from
MUMBAI.
vi. To display the names of the companies and the names of the items in descending
order of company names.
vii. Obtain the outputs of the following SQL queries based on the data given in tables
ITEMS and TRADERS above.
a. SELECT MAX (PRICE), MIN (PRICE) FROM ITEMS;
b. SELECT PRICE*QTY FROM ITEMS WHERE CODE=1004;
c. SELECT DISTINCT TCODE FROM ITEMS;
d. SELECT INAME, TNAME FROM ITEMS I, TRADERS T WHERE | TCODE=T.TCODE
AND QTY<100;
OR
Consider the following tables WORKER and PAYLEVEL and answer (a) and (b) parts of this
question:
Table: WORKER
ECODE |NAME DESIGN PLEVEL |DOJ DOB
Table: PAYLEVEL
TABLE: ACCESSORIES
No Name Price Id
AO1 Mother Board 12000 So1
A02 Hard Disk 5000 S01
A03 Keyboard 500 S02
A04 Mouse 300 S01
(ii) OR
i. Give the syntax of DROP statement. [1]
ii. Consider the following table STORE. Write SQL commands for the following [4]
statements.
Table: STORE
ItemNo Item Scode Qty Rate LastBuy
Page 11
ii. To display ItemNo and Item name of those items from Store table whose
Rate is more than 15 Rupees.
iii. To display the details of those items whose Suppliers code (Scode) is 22
or Quantity in Store (Qty) is more than 110 from the table Store.
iv. To display the Minimum Rate of items for each Supplier individually as
per Scode from the table store.
Section E
34. Write a program to perform binary search on a list of strings arranged in descending [4]
order.
35. Write SQL commands for (i) to (v) on the basis of table EMPLOYEE [4]
TABLE: EMPLOYEE
i. Which command will be used to list the names of the employees, who are more
than 34 years old sorted by NAME.
a. SELECT NAME FROM EMPLOYEE WHERE AGE>34 ORDER BY NAME;
b. SELECT * FROM EMPLOYEE WHERE AGE>34 ORDER BY NAME;
c. SELECT NAME FROM EMPLOYEE WHERE AGE>34;
d. SELECT NAME FROM EMPLOYEE AGE>34 ORDER BY NAME;
Page 12
ii. Write a query to display a report, listing NAME, BASIC, DEPARTMENT and annual
salary. Annual salary equals to BASIC * 12.
iii. Insert the following data in the EMPLOYEE table
11, 'VIJAY', 9300, 'FINANCE', '13/7/98', 35, "M"
iv. Write a query to count the number of employees, who are either working in
PERSONNEL or COMPUTER department.
v. Write the degree and cardinality of the table EMPLOYEE.
—
—
Solutions
—
——
Section A
—
—
(b) False
——
Explanation: False
——
The lists are ordered.
——
2. (a) LIKE operator
.
Explanation: LIKE operator is used in the WHERE clause allows us a search based
S
operation on a pattern.
.
3. (a) s.__getitem__(i)
e
Explanation: It is the correct syntax to call character at index i of string s
e
(c) 5045
e
Explanation: 50#5
e
5. (a) analog signal
e
Explanation: An analog signal is any continuous signal for which the time-varying
e
feature of the signal is a representation of some other time-varying quantity, i.e.,
e
analogous to another time-varying signal. Analog signals produce too much
e
noise. Examples:- Human voice, Thermometer, Analog phones, etc.
e
e
(c) infi.readline()
e
Explanation: readline() function reads a line from the file pointer position.
e
7. (a) localhost
Explanation: localhost
e
e
(b) DDL (Data Definition Language)
e
Explanation: DDL (Data Definition Language) is the language which performs all the
e
operation in defining structure of relation.
.
e
(b) read()
.
Explanation: read( ) function reads the whole file and returns the text as a string.
.
Explanation: None
e
11.
e
(c)1
e
Explanation: 1
12.
e
Explanation: Functions are reusable pieces of programs. They allow you to give a name
e
b
to a block of statements, allowing you to run that block using the specified name
anywhere in your program and any number of times.
13. (a) True
Explanation: True
14.
(b) type conversion
Explanation: type conversion
15. 1. LIKE
16.
(d) Code Division Multiple Access
Explanation: CDMA stands for Code Division Multiple Access. In this, each user is
allocated a unique code sequence, that is used to encode/decode the original data.
17. (a) Both A and R are true and R is the correct explanation of A.
Explanation: The intersection_update() method is different from the intersection()
method since it modifies the original set by removing the unwanted items, on the other
hand, the intersection() method returns a new set removing the unwanted items.
18.
(b) Both A and R are true but R is not the correct explanation of A.
Explanation: CSV stands for "comma-separated values", which is defined as a simple
file format that uses specific structuring to arrange tabular data. It stores tabular data
such as spreadsheets or databases in plain text and has a common format for data
interchange. In python, the csv module is used to handle the CSV files to read/write and
get data from specified columns.
Section B
19 . Answer:
(i) i. The process of altering the characteristics (amplitude or frequency etc.) of a high-
frequency wave called the carrier wave so that it can carry low-frequency
information along with it while being transmitted, is called modulation.
ii. 2G networks primarily involve the transmission of voice information while 3G
technology provides the additional advantage of data transfer.
(ii) OR
i. There are many methods of checking or detecting errors in the data transmitted.
The four simplest ones are:
i. Single dimensional parity checking
ii. Two-dimensional parity checking
iii. Checksum
iv. Cyclic Redundancy Check (CRC)
20 . import MySQLdb
db = MySQLdb.connect("localhost", "Admin", "Ad123", "HMD")
cursor= db.cursor()
cursor.execute("DROP TABLE IF EXISTS Location")
sql="""Create Table location (id Numeric(5) PRIMARY KEY, bidycode varchar(10) Not
Null,
room varchar(6) Not Null , Capacity Numeric(5) Not Null)" " "
cursor.execute(sql)
db.close()
. To = 30 # variable name should be on LHS
for K in range(0, To):# : was missing
if k%4 == 0: # IF should be in lowercase; i.e; if
print (K * 4)
else: # else should be in lower case
print (K + 3)
OR
The above code will give Error because keyword True has been used as variable (in first
line of code True = False). We cannot use keywords as variables or any other identifiers.
22 . Answer:
(i) import mysql.connector as identifier_name
e.g.
import mysgl.connector as mydb
(i) It will add a new record in the database after obtaining values of person-id, and
lastname from user.
OR
fileObject = open ("an.txt", "r")
for line in fileObject:
words = line.split()
for word in words:
for char in word:
if (char.isdigit()):
print(char)
25. def get_ones_digit(num): # return the ones digit of the integer num
ones_Digit = num % 10
return ones_Digit
get_ones_digit function returns the digit at one's position of number num.
Section C
26. Answer:
@ 1=0
for i in range(200, 300):
if(i%7==0) and (i%5!=0)
l.append (str(i))
print(",'.join(l))
(ii) Output
{d':4,'a":1,'c":3,'b": 2}
{d':4,'c":3,'0': 2}
Section D
31. i. Administrative Office is the most suitable location for the main server of this
institution to get efficient connectivity.
| Administrative office |
iii. Switch to be installed in each of these building for connecting computers installed
within the building
iv. Topology: Star Topology
Network Cable Ethernet Cable/Coaxial Cable
32. i. SELECT * FROM ITEMS ORDER BY INAME ASC;
ii. SELECT INAME, PRICE FROM ITEMS WHERE PRICE = > 10000 AND PRICE = < 22000;
iii. SELECT TCODE, COUNT (CODE) FROM ITEMS GROUP BY TCODE;
iv. SELECT PRICE, INAME, QTY FROM ITEMS WHERE QTY > 150;
v. SELECT TNAME FROM TRADERS WHERE (CITY = "DELHI") OR (CITY = "MUMBAI")
vi. SELECT COMPANY, INAME FROM ITEMS ORDER BY COMPANY DESC;
vii. a. 38000
1200
b. 1075000
. TO3
o
d. LED SCREEN 40 DISP HOUSE INC CAR GPS SYSTEM ELECTRONICS sales
OR
i. SELECT NAME FROM WORKER ORDER BY DOB DESC;
o
2 P002
2 P0O03
ii. |Max (DOB) Min (DOJ)
12-Jul-1987 13-Sep-2004
33. Answer:
(i) i. The WHERE clause is used to extract only those records that fulfil a specified
criteria.
iii. SELECT MIN (Price) "Minimum Price", MAX(Price) "Maximum Price", Name
FROM ACCESSORIES
GROUP BY Name;
iv. SELECT Name, Price, SName
FROM ACCESSORIES A, SHOPPE S
WHERE A.ld = S.1d;
but this query enable to show the result because A.Id and S.Id are not identical.
(ii) OR
i. DROP TABLE table_name;
ii. i.SELECT *
FROM STORE
ORDER By LastBuy ;
ii. SELECT ItemNo, Item
FROM STORE
WHERE Rate >15 ;
jii. SELECT *
FROM STORE
WHERE Scode =22 OR Qty > 110 ;
iv. SELECT Scode, Min(Rate)
FROM STORE
GROUP By Scode;
Section E
34. def bsearch(strarr, str):
beg=0
last=len(strarr)-1
while(beg<=last):
mid=(beg+last)/2
if strarr[mid]==str:
return mid
elif strarr[mid]>=str:
beg=mid+1
else:
last=mid-1
else:
return False
---Main---
N=int(raw_input(“Enter no. of elements of the array”.)
Print (“\n Enter strings in descending order:”)
Ar=[" “*N
Foriin range (N):
Ar [i] raw_input (“String”+i+": "
Item = raw_input(“Enter string to be searched:”)
foundat=bsearch(Ar, Item)
if foundat:
print “\n Element found at”, foundat
else:
print "\n String Net Fount"
35. i. (a) SELECT NAME FROM EMPLOYEE WHERE AGE>34 ORDER BY NAME;
ii. SELECT NAME, BASIC, DEPARTMENT, BASIC*12 "Annual Salary" FROM EMPLOYEE;
jii. INSERT INTO EMPLOYEE VALUES(11, 'VIJAY’, 9300, 'FINANCE', ‘13/7/98', 35, 'M");
iv. SELECT COUNT(*) FROM EMPLOYEE
WHERE DEPARTMENT='PERSONNEL" OR DEPARTMENT='COMPUTER";
v. Degree of the given table is 7 and cardinality is 10.