Half Yearly Examination Sample Question Paper
Half Yearly Examination Sample Question Paper
General Instructions:-
• The question paper is divided into 4 sections-A,B,C and D.
• Section A, consists of 12 multiple choice questions. Attempt any 10. Each question carry
1 mark.
• Section B, consists of 12 questions. Each question carries 2 marks.
• Section C, consists of 8 questions. Each question carries 3 marks.
• Section D, consists of 3 questions. Each question carries 4 marks.
1
5. What is the output of the functions shown below?
>>>min(max(False,-4,-6),4,9)
(a) -6
(b) -4
(c) False
(d) 9
6. def interest (p,c,t=2,r=0.09):
return p*t*r
Consider the above defined function, which of the function call are legal.
1) interest(p=1000,c=5)
2) interest(r=0.05,5000,3)
3) interest(500,t=2,r=0.05)
4) interest(c=4,r=0.12,p=5000)
(a) 1,2 and 4
(b) 2 & 3
(c) 1 & 4
(d) 3 & 4
7. What will be the output of the following code?
x=3
defmyfunc():
global x
x+=4
print(x, end=' ')
print(x, end=' ')
myfunc()
print(x, end=' ')
(a) 3 3 3
(b) 3 5 7
(c) 3 7 7
(d) 7 7 7
8. What does readlines() method returns?
(a) Str
(b) a list of lines
(c) list of single characters
(d) list of integers
9. A programmer has confusion in understanding the behaviour of opening a file in “w”
mode. Clear his/her confusion, by suggesting the correct option among the given
below. The behaviour of “w” mode is
(a) Opening fails if the file already exists already.
(b) Opening fails if the file does not exist already.
(c) Opening will be succeeded if file exists with data and keeps the data intact.
(d) Opening will be succeeded, if the file exists replaces the contents, do not exist,
creates a new file.
2
10. Which of the following statements is true with respect to the files in Python?
(a) File can be opened with a file handle using open method without any arguments
(b) File can be opened with a file handle using open method with one argument to read
the file
(c) File can be opened with a file handle using open method with one argument to write
the file
(d) File can be opened with a file handle using open method with one argument to
append the file
14. What do you mean by Primary key and Candidate keys in a table? Explain with the help
of suitable example from a table containing some meaningful data.
15. Consider the following table PREPAID. Write MySQL commands for the statements
given below.
S_No C_Name Model Connection
1 Sita Nokia Airtel
2 Geeta Samsung Idea
3 Ritesh LG BSNL
4 Jayant Micromax Reliance
(i) Delete a column name Model.
(ii) Delete a customer record where connection type is BSNL.
3
16. What are the differences the between WHERE clause and HAVING clause?
17. Write the output of the queries (a) to (d) based on the table, Mobile given below:
M_ID M-Company M_NAME M_PRICE M_Mf_Date
MB001 Samsung Galaxy 15000 12-02-2013
MB003 Nokia N1100 12500 15-04-2011
MB004 Micromax Unite 3 5500 17-10-2016
MB005 Sony XperiaM 25000 20-11-2017
MB006 Oppo SelfieEx 18500 21-08-2010
24. What is the difference between a local variable and global variable? Also, give a suitable
Python code to illustrate both.
25. Write a program to read content from a file “number.txt” and display the sum of
numbers present in file.
for example : if the file contains the following data
4
Total marks in exam is 25
My roll number is 15
My Address is 207, XYZ
Output :
22
26. Write a method cnt_M() in python to read lines from a text file ‘MYNOTES.TXT’, and
display those lines, which are starting with the alphabet ‘M’.
If the ‘MYNOTES.TXT’ contents are as follows:
My first book was
Me and My Family.
It gave me chance to be
Known to the world.
28. Find the output and also trace the flow of execution for the following program.
def increment(n):
n.append([49]):
return n[0], n[1], n[2], n[3]
L=[23,35,47]
m1, m2, m3, m4=increment(L)
print(L)
print(m1, m2, m3, m4)
print(L[3]==m4)
29. Write the outputs of the SQL queries (i) to (iii) based on relations EMP and DESIG given
below:
Table: EMP
E_ID Name Gender Age DOJ Designation
1 Om Prakash M 35 10/11/2009 Manager
2 Jai Kishan M 32 12/05/2013 Accountant
3 Shreya Sharma F 30 05/02/2015 Clerk
4 RakeshMinhas M 40 15/05/2007 Manager
5 Himani Singh F 33 19/09/2010 Clerk
Table: DESIG
Salary E_ID DEPT_ID
45000 1 D101
35000 2 D102
45000 4 D101
5
i) SELECT Designation, count(*) FROM EMP GROUP BY Designation;
ii) SELECT AVG(Age) FROM EMP;
iii) SELECT EMP.Name, EMP.Designation,DESIG.Salary FROM EMP, DESIG WHERE
EMP.E_ID = DESIG.E_ID AND EMP.Age>35;
30. Write a function that takes two numbers and returns the number that has minimum
one’s digit. [For example, if numbers passed are 491 and 278, then the function will
return 491 because it has got minimum one’s digit out of two given numbers (491’s 1 is
<278’s 8)].
32. Write a menu-driven python program using different functions for the following menu:
1. Check no. is Palindrome or not
2. Check no. is Armstrong or not
3. Exit
33. Write queries (a) to (d) based on the tables EMPLOYEE and DEPARTMENT given
below:
Table: EMPLOYEE
6
(a) To display the average salary of all employees, department wise.
(b) To display the name and respective department name of each employee whose
salary is more than 50000.
(c) To display the names of employees whose salary is not known, in alphabetical order.
(d) To display DEPTID from the table EMPLOYEE without repetition.
34. Design a Menu driven program to display the following in the file “textfile.txt”.
1. Number of Vowels
2. Number of Words
3. Frequency of alphabet ‘a’
4. Frequency of word ‘the’
35. A Book store is considering to maintain their inventory using SQL to store the data. As a
database administer, shashank has decided that:
Name of database – BOOK STORE
Name of table – BOOK
The attribute of BOOK are as follows:
Code – alphanumeric of size 10
Bname – character of size 30
Cust_code – float
Price – numeric
Type – character of size 25
Table : BOOK
Code Bname Cust_code Price Type
F101 The priest C083 315 Fiction
L102 German easy C312 410 Literature
C103 Tarzan in the lost C113 100 Comic
world
F102 Untold story C083 215 Fiction
C102 War heroes C113 150 Comic
F103 Poison Garden C083 200 Fiction
(i) Write the degree and cardinality of Table BOOK.
(ii) Insert the following data into the attributes Code, BName, Cust_code and Price.
Code = ‘C105’ Bname = “City heroes” Cust_code= ‘C113’ and Price=75
(iii) Rahul want to remove all the records from the table BOOK. Which command will
he use from the following:
(a) DROP TABLE BOOK;
(b) DELETE FROM BOOK;
(c) DROP DATABASE BOOK STORE;
(d) DELETE BOOKS FROM BOOK;
(iv) Now Rahul wants to display the structure of the table BOOK, i.e, name of the
attributes and their respective data types that he has used in the table. Write the
query to display the same.