Bangalore region QP with MS
Bangalore region QP with MS
Bangalore region QP with MS
SECTION
A
1. State True or False 1
“Dictionaries in python are mutable.”
Ans:True
2. Which of the following is an invalid identifier 1
a)myname b)p9tv c)def d)_new
Ans:c def
3. Which one of the following is the function to get list of keys from a dictionary 1
dict in python?
a. dict.getkeys()
b. dict.getvalues()
c. dict.keys()
d. None Of These
Ans: c dict.keys()
4. Consider the given expression: 1
True OR NOT False AND True
Which of the following will be correct output if the given expression is
evaluated?
(a) True
(b) False
(c) NONE
(d) NULL
Ans:A True
5. Select the correct output of the code: 1
Str=”I will Succeed”
1
lis=str.split(““)
print(lis[-1])
(a) I
(b) will
(c) Succeed
(d) ”I will Succeed”
ANS:c Succeed
6. Which of the following methods will give the current position of the file 1
pointer?
ANS:b tell()
7. Fill in the blank: 1
ANS: c alter
8. Which of the following commands will delete the contents of the table from 1
MYSQL database?
(a) DELETE
(b) DROPTABLE
(c) REMOVETABLE
(d) ALTERTABLE
ANS:a DELETE
9. Which of the following statement(s) would give an error after 1
executing the following code?
T=(8,9,7,6) # Statement 1
print(T) # Statement2
T=(7,9,7,6) # Statement3
T[1]=8 # Statement4
T=T+(1,2,3) # Statement5
(a) Statement3
(b) Statement4
(c) Statement5
(d) Statement 4 and5
ANS:b statement 4
2
10. Fill in the blank: 1
ANS:b read
12. Which of the following can be used as command to get the structure of a table in 1
mySQL
(a) DESCRIBE
(b) UNIQUE
(c) DISTINCT
(d) NULL
ANS:a DESCRIBE
13. Fill in the blank: 1
Is the protocol used for server to server mail transfer?
ANS:b SMTP
ANS: b 64
3
16. Which function is used to establish connection between python and SQL 1
database?
(a) connection
(b) connect
(c) getconnection
(d) getconnect
ANS:b connect
Q17 and 18 are ASSERTION AND REASONING based questions. Mark the correct
choice as
(a) Both A and R are true and R is the correct explanation for A
(b) Both A and R are true and R is not the correct explanation for A
(c) A is True but R is False
(d) A is false but R is True
17. Assertion (A):-Functions in a program increases the modularity and readability 1
of the program
Reasoning (R):-Usage of Functions increases the execution speed of the
program
18. Assertion (A): If a file is opened in binary mode its contents are viewed as a 1
sequence of bytes.
Reason (R): A text file also can be opened in binary mode
ANS: b Both A and R are true and R is not the correct explanation for A
SECTION
B
19. Rahul has written a code to input a number and return its reverse. His code is 2
having errors. Rewrite the correct code and underline the corrections made.
def reverse()
n=int(input("Enter number :: ")
rev=0
while(num>0):
r=num%10
rev=rev*10+r
num=num//10
return rev
ANS:
def reverse():
n=int(input("Enter number :: ")
rev=0
while(num>0):
r=num%10
rev=rev*10+r
num=num//10
return rev
OR
ANS:MODULATOR DEMODULATOR
2marks for correct explanation.
OR
25. Explain the use of DISTINCT keyword in python with appropriate example 2
ANS:DISTINCT keyword discards duplicate vales
1 mark for explanation and 1 mark for example
OR
SECTION C
b)Write the outputof the queries (i) to (iv) based on the table EMPLOYEE given
below
Empid Empname Salary Deptid
6
E1 Prabhath 12000 D1
E2 Nikhil 14000 D1
E3 Devansh 10000 D2
E4 Debraj 15000 D3
E5 Aron 18000 D1
(iii)
Empname
Aron
Debraj
1/2 marks
(iv)
Sum(Salary)
33000
1/2 marks
27. Write a method COUNTLINES() in python to read lines from text file 3
MYSTORY.TXT and display the count of lines which are starting with letter T
Example:if the file content is as follows:
Trees are the precious
We should protect trees
This way we can serve nature
ANS:
def COUNTLINES():
fp=open("MYSTORY.TXT","r")
7
count=0
lines=fp.readlines()
for line in lines:
if(line[0]=="T"):
count=count+1
print("The number of lines starting with letter T :",count)
OR
Example:
28. (a) Write the outputs of the SQL queries (i) to (iv) based on the 3
relations Teacher and Placement given below:
BOOK
Book_id Book_name Price Qty Author_id
1001 My first C++ 323 12 204
1002 SQL basics 462 6 202
1003 Thunderbolts 248 10 203
1004 The tears 518 3 204
AUTHOR
Author_id Author_name Country
201 William Hopkins Australia
202 Anita India
203 Anna Roberts USA
204 Brain&Brooke Italy
For example:
If L contains [1,2,3,4,5,6,7,8]
Write the following user defined functions to perform given operations on the
stack named ‘stud_details’:
(i) Push_element() - To Push an object containing nameand
age of students who live in hostel “Ganga” to the stack
(ii) Pop_element() - To Pop the objects from the stack and display
them. Also, display “Stack Empty” when there are no elements in
thestack.
For example:
If the lists of customer detailsare:
[“Barsat”,17,”Ganga”]
[“Ruben”, 16,”Kaveri”]
[“Rupesh”,19,”Yamuna”]
The stack should contain
[“Barsat”,17,”Ganga”]
The output should be:
[“Barsat”,17,”Ganga”]
Stack Empty
ANS:
stud_details=[]
def push_element(lis):
if(lis[2]=="Ganga"):
stud_details.append([lis[0],lis[1]])
def pop_element():
while(len(stud_details)>0):
print(stud_details.pop())
print("Stack Empty")
OR
31
HiTech Training center, a Mumbai based organization is planning to
expand their training institute to Chennai. At Chennai compound,
they are planning to have three different blocks for admin, training
and accounts related activities. As a network consultant you have to
suggest some network related solutions to the organization
Suggest the most suitable block to house the server at Chennai block for 1
ii) best and effective connectivity.
Suggest the type of network for the new training institute and draw 1
iii) the cable layout for the Chennai office
Suggest a hardware/software that would provide the data security 1
iv) for entire network of Chennai region.
Suggest a device that shall be needed to provide wireless 1
v) internet access to all smart phones/laptop users in Chennai office.
Suggest the protocol used for video conferencing between Chennai
11
office and Mumbai office
ANS:
i)Training Block
ii)LAN
iii)FIREWALL
iv)ACCESS POINT
v)H.323 or SIP
32. (a) Write the output of the code given below: 2+3
val=4
def findval(m,n=10):
val=0
val=val+m*n
a=10
b=20
findval(a,b)
print(val,end="-")
findval(a)
print(val,end="-")
ANS:4-4-
(b) The code given below inserts the following record in the table
Employee:
import mysql.connector
from mysql.connector import Error
connection = mysql.connector.connect(host='localhost',
database='Employee',
user='root',
password='tiger')
cursor=_______________________#STATEMENT1
empid=int(input("enter Empid")) 12
name=input("enter name")
salary=float(input("ENTER SALARY"))
result = __________________________#STATEMENT2
___________________________________#STATEMENT3
ANS:
STATEMENT1:connection.cursor()
STATEMENT2:cursor.execute("insert into employee
values(%s,%s,%s)",(empid,name,salary))
STATEMENT3:connection.commit()
OR
(b) The code given below reads the following record from thetable
named Employeeand displays only those records who have Salary
greater than 25000:
import mysql.connector
connection = mysql.connector.connect(host='localhost',
database='Employee',
user='root',
password='tiger')
cursor=________________________#STATEMENT1
_________________________________________#STATEMENT2
13
records = _____________________________#STATEMENT3
for row in records:
print("Empid",row[0],end=" ")
print("name",row[1],end=" ")
print("salary",row[2],end=" ")
print()
ANS:
Statement 1 :connection.cursor()
Statement 2 :cursor.execute("select * from employee where salary>25000")
Statement 3:cursor.fetchall()
33. What is a csv file? 5
Write a Program in Python that defines and calls the following user defined
functions:
def COUNTSTUDENTS():
file=open("student.csv","r")
reader=csv.reader(file)
print("No of students",len(reader))
OR
34. Rahul created following table TRAVEL to store the travel details 1+1+2
ANS:
a)(i)TNO (ii)degree-9 cardinality-6
iii)a.INSERT INTO TRAVEL VALUES(110,’BIMAL’,’28-11-
2022’,200,’VOLVOBUS’,40)
b.UPDATE TRAVEL SET KM=KM+10 WHERE VTYPE=’VOLVO
BUS’
OR (Option for part iii only)
17