Puterscience SQP Set3
Puterscience SQP Set3
Puterscience SQP Set3
Page 1 of 7
11. The correct syntax of load( ) is: 1
a) <objectvariable>=pickle.load(<fileobject>) b) pickle.load(<fileobject>, <objectvariable>)
c) <fileobject>.load(<objectvariable>) d) <objectvariable> = <fileobject>.load( )
12. The clause is used to display result of an SQL query in ascending or descending order 1
with respect to specified attribute values
13. Fill in the blank: 1
is the protocol used for transferring files from one machine toanother.
a) HTTP b) FTP
c) SMTP d) VOIP
Page 2 of 7
21. Assertion (A) : The tell( ) method returns an integer that specifies the current position of the file 1
object in the file.
Reason (R) : Offset can have any of the three values – 0, 1 and 2
SECTION B
22. Observe the following Python code very carefully and rewrite it after removing all syntactical errors 2
with each correction underlined.
DEF result_even( ):
x = input(“Enter a number”)if (x % 2 = 0) :
print (“You entered an even number”)else:
print(“Number is odd”)
even ( )
23. Write two points of difference between LAN and WAN. 2
(OR)
Write two points of difference between HTTP and SMTP.
24 (a) Given is a Python string declaration: 1
str1="!!Welcome to Python!!"
Write the output of: 1
print(str1[::-2])
(b) Write the output of the code given below:
dict1 = {"name": "Suman", "age": 36}
dict1['age'] = 27
dict1['address'] = "Chennai"
print(dict1.keys())
25. Write a Python program that executes division and handles an ArithmeticError exception if there is 2
an arithmetic error.
26. (a) Expand the following: 1
i) XML ii) HTML
(b) What is the use of PPP in computer networks? 1
27. (a) Write two points of difference between LAN and WAN 2
(OR)
(b) Write two points of difference between HTTP AND SMTP
28. Differentiate between COUNT(*) and SUM( ) functions in SQL with appropriate example. 2
(OR)
Categorize the following commands as DDL or DML: CREATE, DROP, UPDATE, INSERT
SECTION C
29. Write a function in python to count the number lines in a text file ‘Country.txt’ which is starting 1+2
with an alphabet ‘W’ or ‘H’. If the filecontents are as follows:
Whose woods these are I think I know.
His house is in the village though;
He will not see me stopping here
To watch his woods fill up with snow.
The output of the function should be:W or w : 1
H or h : 2
(OR)
Write a user defined function countwords( ) to display the total number of words present in the text
file “Quotes.Txt”. If the text file has the following data written in it:
Page 3 of 7
The countwords() function should display the output as:
Total number of words : 40
30. A list, NList contains following record as list elements: 3
[City, Country, distance from Delhi]
Each of these records are nested together to form a nested list. Write the following user defined
functions in Pythons to perform the specified operations on the stack named travel.
(a) Push_element(travel,NList): It takes the nested list as an argument and pushes a list object
containing name of the city and country, which are not in India and distance is less than 3500 km
from Delhi.
(b) Pop_element(travel): It pops the objects from the stack and displays them. Also, the function
should display "Stack Empty: when there are no elements in the stack.
(c) peep(travel): This function displays the topmost element of the stack without deleting it. If the
stack is empty, the function should display ‘None’.
For example:
If the nested list contains the following data:
NList=[["New York", "USA",11734],["Naypyidaw","Myanmar", 3219], ["Dubai","UAE",2194],
["London","England",6693], ["Gangtok","India",1580], ["Columbo","Sri Lanka",3405]]
The stack should contain:
["Naypyidaw","Myanmar"]
["Dubai","UAE"]
["Columbo","Sri Lanka"]
The output should be:
["Columbo","Sri Lanka"]
["Dubai","UAE"]
["Naypyidaw","Myanmar"]
Stack Empty
OR
Write a function in Python(SItem) where, SItem is a dictionary containing the details of stationary
items - {Sname:Price}.
(a) Push(SItem, Price): The function should push the names of those items in the stack who have
price greater than 75. Also display the count of elements pushed into the stack.
(b) Pop(SItem): this function pops the topmost book record from the stack and returns it. If the stack
is already empty, the function should display “None”
(c) Traverse(SItem) : This function is show all element of the stack. If the stack is empty, the
function should display “Empty Stack”
For example:
If the dictionary contains the following data:
Ditem={"Pen":106,"Pencil":59,"Notebook":80,"Eraser":25}
The stack should contain
Notebook
Pen
The output should be
The count of elements in the stack is 2
31. Predict the output of the following Python code: 3
def Bigger(N1,N2):
if N1>N2:
return N1
else:
return N2
L=[32,10,21,54,43]
Page 4 of 7
for c in range (4,0,-1):
a=L[c]
b=L[c-1]
print(Bigger(a,b),'@', end=' ')
(OR)
SECTION D
32. As part of Fit India Campaign, Suresh has started a juice shop that serveshealthy juices. As his 1+1+2
database administrator, answer the following questions based on the data given in the table below.
Table : HEALTHYDRINKS
Page 5 of 7
different fields as mentioned below:
Code Item Company Price Quantity
T01 Television LG 43000 15
T02 Television Sony 55000 20
F01 Refrigerator LG 35000 10
(i) Now display the details of all televisions of various comparisons from the file.
(ii) Count the number of records those item quantity more than 20.
34. In a Database Company, there are two tables given below: 4
Table: SALES
SALESMANID NAME SALES LOCATIONID
S1 ANITA SINGH ARIRA 250000 102
S2 Y.P. SINGH 1300000 101
S3 TINA JAISWAL 1400000 103
S4 GURDEEO SINGH 1250000 102
S5 SIMI FAIZAL 1450000 103
Table: LOCATION
LOCATIONID LOCATIONNAME
101 Delhi
102 Mumbai
103 Kolkata
104 Chennai
Write SQL queries for the following :
(i) To display SalesmanID, Name of salesman, LocationID with corresponding location names.
(ii) To display name of salesmen, sales and corresponding location names who have achieved Sales
more than 1300000.
(iii) To display names of those salesmen who have ‘SINGH’ in their names.
(iv) (A) Indentify Primary key in the table SALES. Give reason for your choice.
OR
(B) Write SQL command to change the LocationID to 104 of the Salesman with ID as S3 in the
table ‘SALES’.
35. The code given below inserts_and_show() the following record in the table Employee: 4
Empid – integer
Name – string
salary-float
Note the following to establish connectivity between Python and MYSQL:
• Username is root
• Password is tiger
• The table exists in a MYSQL database named Empolyee.
• The details (Empid, Name, salary) are to be accepted from the user.
SECTION E
36. Python University is setting up its academic blocks at Chennai 5
and is planning to set up a network. The University has 3 academic blocks and one Human Resource
Center as shown in the diagram below:
Page 6 of 7
Center to Center distances between various blocks/center is as follows:
Page 7 of 7