0% found this document useful (0 votes)
25 views7 pages

Half Yearly Examination Sample Question Paper

Uploaded by

ecfpune2016
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views7 pages

Half Yearly Examination Sample Question Paper

Uploaded by

ecfpune2016
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

HALF YEARLY EXAMINATION

SAMPLE QUESTION PAPER


Class - XII Subject – Computer Science
Time – 3 Hours Maximum Marks-70

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.

SECTION-A (Multiple Choice questions) [10x1=10 Marks]

1. Which of the following is a DML command?


(a) DROP
(b) INSERT
(c) ALTER
(d) CREATE
2. Identify the valid declaration of T:
T = {“Roll”:123, “Name”: “Hiya”, “Class”:12, “Subject” : ”Computer Science”}
(a) dictionary
(b) string
(c) tuple
(d) list
3. Find the valid identifier from the following
(a) Tot$balance
(b) TRUE
(c) 4thdata
(d) break
4. Suppose a tuple T is declared as T=(10,20,30) and a list L=["mon", "tue", "wed", "thu",
"fri", "sat", "sun"], which of the following is incorrect ?
(a) min(L)
(b) L[2] = 40
(c) T[3] = “thurs”
(d) print( min(T))

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

11. Number of records in a table is called


(a) Cardinality
(b) Data inconsistency
(c) Degree
(d) Record Number
12. Suppose content of ‘DATfile.txt’ is
The Education of a women is the education of a family.
What will be the output of the following code?
myfile=open(“DATfile.txt”)
X=myfile.read()
Y=X.count(‘of’)
print(y)
myfile.close()
(a) 2
(b) 3
(c) 4
(d) 5

SECTION-B [12X2=24 Marks]

13. Give the output given by the following code fragments.


(a) y=str(123)
print(y*3)
(b) 5<10 and 10<5 or 3<18 and not 8<18

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

(a) Select Max(M_Mf_Date), Min(M_Mf_Date) from Mobile;


(b) Select * from Mobile WHERE M_PRICE>15000 AND Like “S%”;
(c) Select M_Mf_Date from Mobile WHERE M_Name IN (“Galaxy”,”Unite3”);
(d) Select AVG(M_Price) from Mobile;

18. Differentiate between Text file and Binary file.


19. Write a program to accept five numbers from the user and write in a file “number.txt”
in separate lines.
20. Write a program in Python to copy the alternate lines from file “data.txt” to “story.txt”
21. What do you mean by default parameters? Explain with the help of suitable example.
22. Write definition of a method ODDSum(NUMBERS) to add those values in the list of
NUMBERS, which are odd.
Sample Input Data of the List
NUMBERS=[20,40,10,5,12,11]
OUTPUT is 16

23. Write the output of the following code:


v=5
def d(N):
global v
v = 25
if N%9==0:
v=v*N
else:
v = v ** N
print(v, end="#")
d(2)
print(v)

24. What is the difference between a local variable and global variable? Also, give a suitable
Python code to illustrate both.

SECTION-C [8X3=24 Marks]

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.

The output of the function should be:


Count of lines starting with Meis: 2
27. Write a function RevText() to read a text file “ Story.txt “ and Print only word starting
with ‘I’ in reverse order . Example: If value in text file is: INDIA IS MY COUNTRY
Output will be: AIDNI SI MY COUNTRY.

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)].

31. Write the output of the following code fragment:


deffunc(b):
global x
print(‘Global x=’, x)
y=x+b
x=7
z=x–b
print(‘Local x = ‘,x)
print(‘y = ‘,y)
print(‘z = ‘,z)
x=5
func(10)

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

SECTION-D [3X4=12 Marks]

33. Write queries (a) to (d) based on the tables EMPLOYEE and DEPARTMENT given
below:

Table: EMPLOYEE

EMPID NAME DOB DEPTID DESIG SALARY


120 Alisha 23-Jan-1978 D001 Manager 75000
123 Mamta 04-April-1992 D002 AO 59000
129 Navjot 12-Jul-1971 D003 Supervisor 40000
130 Jimmy 30-Dec-1980 D004 Sales Rep
131 Faiz 06-Apr-1984 D001 Dep Manager 65000
Table : DEPARTMENT

DEPTID DEPTNAME FLOORNO


D001 Personal 4
D002 Admin 10
D003 Production 1
D004 Sales 3

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.

You might also like