HimeTest1-MS
HimeTest1-MS
General Instructions:
(i) This question paper contains five sections, Section A to E.
(ii) All questions are compulsory.
(iii) Section A have 21 questions carrying 01 mark each.
(iv) Section B has 07 Very Short Answer type questions carrying 02 marks each.
(v) Section C has 03 Short Answer type questions carrying 03 marks each.
(vi) Section D has 04 Long Answer type questions carrying 04 marks each.
(vii) Section E has 02 questions carrying 05 marks each.
(viii) All programming questions are to be answered using Python Language only.
11 . Identify the correct possible output for the following Python code: 1
import random
for N in range(2,5,2):
print(random.randrange(1,N,end=’@’)
(a) 1@3@5@ (b) 2@3@
(c ) 1@4@ (d)1@3@
Ans: (d) 1@3@
12 Which of the following is not correct in context of Positional and Default parameters 1
in Python functions?
(a) Default parameters must occur to the right of the Positional parameters.
(b) Positional parameters must occur to the right of the Default parameters.
(c )Positional parameters must occur to the left of Default parameters.
(d) All parameters to the right of Default parameters must also have Default value.
Ans: (b) Positional parameters must occur to the right of the Default
parameters.
Question no,20 and 21 are the 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.
Reason: The message switching and packet switching techniques are the same.
Ans: (c)A is true but R is false.
SECTION-B (7X2=14)
22. A) List out all the mutable and immutable data types in python.
B) Identify the types of following tokens. (2)
i) _Var_ ii) in
Ans:
A)1 mark for correct classification of data types
B) i)Identifier ii) Operator (1/2 mark for each)
23. i) What is the use of Identity operator? Give an example.
(2)
ii) Explain the use of ceil() and fabs() functions of math module with an example.
Ans:
i) Identity operator – is, is not – compares memory location
(1/2 mark) and (1/2 mark for an example)
ii) ceil() – returns maximum integer and fabs() – returns absolute value
(1/2 mark) and (1/2 mark for an example)
24. If exam=[‘eng’, ‘phy’, ‘che’, ‘cs’, ‘bio’], then
(Answer using builtin functions only)
(I)
A) Write a statement to insert subject ’math’ as last element (2)
OR
B) Write a statement to display the list in alphabetical order.
(II)
A) Write a statement to delete the element ‘che’.
OR
B) Write a statement to reverse the elements of list exam.
Ans: (I)
A) exam.append(‘math’)
OR
B) exam.sort() / exam.sort(reverse=False)
(1 mark for correct answer)
(II)
A) exam.remove(‘che’)
OR
B) exam.reverse()
(1 mark for correct answer)
25. Identify the correct output(s) of the following code. Also write the minimum and
the maximum possible values of the variable t.
import random
W=[‘Pen’, ‘Pencil’, ‘Eraser’, ‘Bag’, ‘Book’]
for i in range(2,3):
(2)
f=random.randint(i,3)
t=random.randint(i-1,3)
print(W[f], W[t], sep= “:”)
26. A)Write any two differences between circuit switching and packet switching.
OR
(2)
B)Expand the following terms.
i) VoIP ii) GPRS iii) FTP iv) Wi-Fi
Ans:
A) Any two correct differences (1 mark for each difference)
OR
B)
i) VoIP – Voice over Internet Protocol
ii) GPRS – General Packet Radio Service
iii) FTP – File Transfer Protocol
iv) Wi-Fi - Wireless Fidelity
(1/2 mark for each expansion)
I)
27.
A)Differentiate WHERE and HAVING clause in SQL with an
example
OR (2)
B)Write any two differences between DELETE and DROP commands.
II)
A) Satheesh has created a database “school” and table “student”. Now he
wants to view all the databases present in his laptop. Help him to write SQL
command for that, also to view the structure of the table he created.
OR
B) Write an SQL command to add the new column PURCHASE_DATE of
an already existing table named PRODUCT.
Ans:
A)difference - (1/2 mark), example – (1/2 mark)
OR
B) Any two correct differences (1/2 mark for each difference)
II)
A) SHOW DATABASES; (1/2 mark)
DESCRIBE STUDENT; / DESC STUDENT; (1/2 mark)
OR
B) ALTER TABLE PRODUCT
ADD PURCHASE_DATE DATE;
(1 mark)
28. Observe the following code carefully and rewrite it after removing all syntax and
logical errors. Underline all the corrections made.
def sepo_n(NUM):
SUM=0 (2)
PROD=1
for j in range(10:NUM)
if j%2=0:
SUM=SUM+j
else:
PROD=*j
print(SUM,PROD)
N=input(“Enter a number”)
seop_n(N)
Ans:
def sepo_n(NUM):
SUM=0
PROD=1
for j in range(10,NUM):
if j%2==0:
SUM=SUM+j
else:
PROD *= j
print(SUM,PROD)
N=int(input(“Enter a number”))
seop_n(N)
Example:
OR
Example:
Ans:
def AICount():
f=open("DET
AILS.txt",'r')
data=f.read()
A=I=0
for j in data:
if j in ‘Aa’
A+=1
If j in ‘Ii’:
I+=1
print (A)
print(I)
f.close()
AICount()
OR
def CNT_DWORDS():
f= open(“QUOTES.TXT”,’r’)
S=F.read()
Wlist=S.split()
Count=0
for W in Wlist:
if W[-1].isdigit():
Count+=1
print(“NO.OF words ending with a digit are”,count)
text = "pythoncode"
count = {}
c=0
lst = []
for w in text:
if w not in lst:
lst.append(w)
count[w] = 0
c= c + 1
count[w] = count[w] + 1
print(count)
print(lst)
OR
OR
( ½ mark for each Boolean value and 1 mark for printing symbols)
½ mark deducted for not printing symbols
SECTION-D (4X4=4)
32. Consider the table EMPLOYEES as given below: 4
Emp_ID Name Department Salary Joining_Date
101 Amit IT 50000 2020-05-15
102 Nisha HR 60000 2019-07-10
103 Rohit IT 45000 2021-02-25
104 Riya Finance 55000 2018-11-23
105 Arjun Marketing 40000 2021-03-05
A) Write the following queries:
i) To display the total salary for each department, excluding departments
with a total salary greater than 100,000.
ii) To display the EMPLOYEES table sorted by salary in ascending order.
iii) To display the distinct department names from the EMPLOYEES table
iv) Display the total salary of employees whose joining date is before 2020-
01-01
OR
B) Write the output for the following queries:
i) SELECT name, salary from employees where salary >50000;
ii) SELECT department, Count(*) as total_employees FROM
employees GROUP BY department;
iii) SELECT * FROM EMPLOYEES where department=’IT’;
SELECT min(salary) from employees;
Ans:
i) Select department, sum(salary) as total_salary from employees group by
department having total_salary<=100000;
ii) SELECT * FROM EMPLOYEES ORDER BY SALARY;
iii) SELECT DISTINCT DEPARTMENT FROM EMPLOYEES;
IV) SELECT SUM(SALARY) FROM EMPLOYEES WHERE JOINING_DATE < ‘2020-01-
01’;
(4 x 1 mark for each correct query)
OR
B) i)
name salary
nisha 60,000
riya 55,000
ii)
Department Total_employees
IT 2
HR 1
Finance 1
Marketing 1
iii)
Emp_ID Name Department Salary Joining_Date
101 Amit IT 50,000 2020-05-15
103 Rohit IT 45,000 2021-02-25
i) min(salary)
40,000
(4 x 1 mark for each correct output)
33 Write a program in Python that defines and calls the following user 4
defined functions:
i) add()-To add the data of a student to a CSV file ‘school.csv’. Each record
consists of a list with field elements as stuid, sname and marks to store
student id, student name and student marks respectively.
ii) Search()- To display the records of the student whose marks is more than
80.
Ans:
33) import csv
(i) def ADD():
fout=open("school.csv","a",newline="\n")
wr=csv.writer(fout)
stuid=int(input("Enter student id :: "))
sname=input("Enter student name :: ")
marks=int(input("Enter mark :: "))
lst=[stuid,sname,marks]
wr.writerow(lst)
fout.close()
(½ mark for opening in the file in right mode)
(½ mark for correctly creating the reader object)
(½ mark for correctly checking the condition)
(½ mark for correctly displaying the records
(ii)
import csv
def search():
fin=open("school.csv","r",newline='\n')
data=csv.reader(fin)
found=False
print("The Details are")
for i in data:
if int(i[2])>80:
found=True
print(i[0],i[1],i[2])
if found==False:
print("Record not found")
fin.close()
print("Now displaying")
search()
(½ mark for opening in the file in right mode)
(½ mark for correctly creating the reader object)
(½ mark for correct use of counter)
(½ mark for correctly displaying the counter)
34 Write SQL queries for (i) to (iv) on the basis of table ITEMS and Traders 4
Table: ITEMS
CODE INAME QTY PRICE COMPANY TCODE
1001 Digital pad 120 11000 XENITA T01
1006 Led screen 70 38000 SANTORA T02
1004 Car Gps 50 21500 GEOKNOW T01
system
1003 Digital 160 8000 DIGICLICK T02
Camera
1005 Pen drive 600 1200 STOREHOME T03
TABLE: TRADERS
TCODE INAME CITY
T01 ELECTRONIC SALES MUMBAI
T03 BUSY STORE CORP DELHI
T02 DISP HOUSE INC CHENNAI
Ans:
35) import msq.connector as m
con=m.connect(host=”localhost”, username:”admin”, password:”admin@123”,
database=”club”)
cur=con.cursor()
cur.execute(“select * from member where activity=”GYM”)
r=cur.fetchall()
for i in r:
print(i[0],i[1],sep=””)
(½ mark for correctly importing the connector object)
(½ mark for correctly creating the connection object)
(½ mark for correctly creating the cursor object)
(½ mark for correctly inputting the data)
(½ mark for correct creation of first query)
(½ mark for correctly executing the first query with commit)
(½ mark for correctly executing the second query)
(½ mark for correctly displaying the data)
SECTION-E (2X5=10)
36 A binary file “Book.dat” has structure [Bookno, Book_name, Author,Price]. 5
(i) Write a user defined function createfile(). To input data for a record and add to
Book.dat
(ii) Write a function countrec(Author) in Python which accepts the Author name as
parameter and count and return number of books by the given Author are stored in
the binary file Book.dat
Ans: (i)
import pickle
def createfile():
fob=open(“Book.dat”,”ab”)
Bookno=int(input(“Enter book number:”))
Book_name=input((“Enter Author name:”)
Author = input(“Enter Author name:”)
price=int(input(“Price of book))
rec =[Bookni, Book_name, Author,price]
pickle.dump(rec,fob)
fob.close().
(ii)
def countrec(Author):
fob=open(“Book.dat”,”rb”)
num = 0
try:
while True:
rec=pickle.load(fob)
if Author= =rec[2]:
num=num+1
print(rec[0],rec[1],rec[2],rec[3])
except():
fob.close()
return num
37 “Pratham” an NGO ,to provide education to children in the slums of Mumbai and it 5
has grown both in scope and geographical area,It is planning to setup its new
campus at Gujarat . The Gujarat campus has four(04) UNITS as shown below:
ADMIN
TRAINING
UNIT
UNIT
FINANCE
RESOURCE
UNIT
UNIT
UNIT NO.OF.COMPUTERS
ADMIN 140
FINANACE 25
TRAINNG 80
RESOURCE 65
OR
B) Mumbai firm is planning to connect to its Finance department in
Gujarat which is approximately 500 km away. Which type of network out
of LAN,WAN or MAN will be formed ?Justify your answer
Ans:
i)
TRAINING
ADMIN
FINANACE
RESOURCE
ii) ADMIN block.It has maximum number of computers
iii) Switch
iv)Repeaters
v)A) Satellie
OR
B)WAN .It covers larger geographical area
(1 mark for each correct answer)