Xii CS Term-1 Retestqp
Xii CS Term-1 Retestqp
1
N.S.N MEMORIAL SENIOR SECONDARY (a) Not null (b)Alternate key (c) Primary key (d) Check
SCHOOL 8 Choose the correct command to delete an attribute A from a 1
Thirumurugan Salai, Thirumurugan Nagar, Chitlapakkam, Chennai – 64 relation M.
TERMINAL EXAMINATION – I 2024 – 2025 a) ALTER TABLE M DROP column A b) ALTER TABLE M DELETE A
12C1 Marks: 70 c) ALTER TABLE DROP column A FROM M d) DELETE A FROM M
Roll No Duration: 3 Hour 9 In the relational model, relationships among relations/table are 1
created by using ______ keys.
General Instructions: a) composite b) alternate c) candidate d) foreign
1. This question paper contains five sections, Section A to E. 10 Which of the following aggregate functions not ignore NULL 1
2. All questions are compulsory. values?
3. Section A has 18 questions carrying 01 marks each. a) COUNT b) MAX c) SUM d) COUNT (*)
4. Section B has 07 Very Short Answer type questions carrying 02 marks 11 The correct statement(s) to place the file handle fp1 to the 8th 1
each. byte from the end position is:
5. Section C has 05 Short Answer type questions carrying 03 marks each. a) fp1.seek(8) b) fp1.seek(8, 0)
6. Section D has 03 Long Answer type questions carrying 05 marks each. c) fp1.seek(8, 1) d) fp1.seek(-8, 2)
7. Section E has 02 questions carrying 04 marks each. 12 Which of the following is a DDL command? 1
8. All programming questions are to be answered using Python Language a) SELECT b) UPDATE c) CREATE d) DELETE
only. 13 What is the value of the expression: 2**3**2//3*2 1
SECTION – A 18 x 1 = 18 a) 10 b) 42 c) 85 d) 340
1 Numbers = ( 4, 8, 9, 2.6, 5 ) 1 14 For a binary file, seek( ) method accepts: 1
print(type(Numbers)) a) Exactly one parameter b) Exactly two parameters
a) List b) Tuple c) class<list> d) class<tuple> c) At most one parameter d) At most two parameters
2 What will be the output for the following Python statements? 1
15 The read() method returns: 1
D= {“Amit”:90, “Reshma”:96, “Suhail”:92, “John”:95}
print(“John” in D, 90 in D, sep= “#”) a) String b) A list of integers
a) True#False b)True#True c) False#True d) False#False c) A list of single characters d) A list of strings
3 Consider the given expression: 8 and not 3>4 or 2 1 16 What will be the output of the following code? 1
Which of the following is the correct value of the expression? d1={1:2,3:4,5:6}
a) 8 b) True c) 2 d) False d2=d1.setdefault(4,9)
4 Which of the following functions is the header correct? 1 print(d2)
a) def study(a=2, b=5, c) : b) def study(a=2, b=9, c=5) : Q17 and 18 are ASSERTION AND REASONING based questions.
c) def study(a, b=2, c): d) none of the above Mark the correct choice as
5 Which of the following modes in the file opening statement creates 1 a) Both A and R are true and R is the correct explanation for A
an error if the file does not exist? b) Both A and R are true but R is not the correct explanation for A
a) r+ b) w+ c) a+ d) Both (b) and (c) c) A is True but R is False
6 Which of the following does not support slicing in Python? a) list 1 d) A is false but R is True
a) list b)tuple c) str d) dictionary 17 Assertion (A): A global keyword is used inside a function to 1
enable the function to alter the value of a global variable.
Page 1 of 5
Reasoning (R): A global variable cannot be accessed by a 24 What will be the output of the following code: 2
function without using a global keyword. def Alter(x, y = 10, z=20):
18 Assertion (A): [1,2,3] is an invalid key for a dictionary in Python. 1 k=x+y-z
Reason (R): Only numbers and strings can be the keys of a print(k)
dictionary in Python. Alter(40,200,30)
SECTION – B 7 x 2 = 14 Alter(20,30)
19 Priya has written code to input an integer and display its first 10 2 Alter(100)
multiples (from 1 to 10). Her code is having errors. Rewrite the 25 1) Which of the following statements is false? 1
correct code and underline the corrections made. a) A try-except block can have more than one except +
n=int(input(Enter an integer: ) statement 1
for i in range(1,11) b) One block of except statement cannot handle multiple
m=n*k exceptions
print(m,End=' ' ) c) The final block is always executed
20 Name any four aggregate functions of SQL. 2 d) When 1 == "1" is executed, no exception is raised
21 What will the output of the following Python code? 2 2) Consider the statements given below and then choose the
result=0 correct output from the given options:
numberList=[10,20,30] pride="#G20 Presidency"
numberList.append(40) print(pride[-2:2:-2])
print(numberList) a) ndsr b) ceieP0 c) ceieP d) yndsr
result=result+numberList.pop() 5 x 3 = 15
print(result) SECTION - C
print(numberList) 26 Predict the output of the Python code given below: 3
22 Write the output of the following: 2 Write the output of the following:
def JDI(N1,N2=1): L = [5,10,15,1]
if type(N1)==list: G=4
return N1[N2] def Change(X):
else: return N1-N2 global G
N=len(X)
print(N1,N2,sep='#',end=' ')
for i in range(N):
NUM=[15,20] X[i] += G
NUM.append(JDI(NUM,0)) Change(L)
NUM.append(JDI(10)) for i in L:
print(NUM) print(i,end='$')
27 a) Consider the following tables BOOKS and ISSUED in a database 3
23 a) Relation emp has 10 tuples and 5 attributes. Relation dept has 1 named “LIBRARY”. Write SQL commands for the statements (i) to
3 tuples and 7 attributes. When a CROSS JOIN is achieved between + (iii).
emp and dept, how many tuples would the resultant set have? 1 TABLE:BOOKS
b) The ____ clause is used to display the result of an SQL query in BID BNAME AUNAME PRICE TYPE QTY
ascending or descending order for specified attribute values.
Page 2 of 5
COMP11 LET US C YESHWANT 350 COMPUTER 15 29 Write a function countPYTHON( ) which read a text file ‘myfile.txt’ 3
and print the frequency of the words ‘python’ in it (ignoring case of
GEOG33 INDIA MAP RANJEET P 150 GEOGRAPHY 20
the word).
HIST66 HISTORY R BALA 210 HISTORY 25 Example: If the file content is as follows:
PYTHON is a high-level programming language. python is easy to
COMP12 MY FIRST C VINOD DUA 330 COMPUTER 18
learn. python is case sensitive language.
LITR88 MY DREAMS AEVIND AD 470 NOBEL 24 The countPYTHON( ) function should display the output as:
Frequency of India is 3
TABLE: ISSUED
(OR)
BID QTY_ISSUED
Write a function countVowel() in Python, which should read each
HIST66 10 character of a text file “myfile.txt” and then count and display the
COMP11 5 count of occurrence of vowels (including small cases and upper
LITR88 15 case).
Example:
i) Display book name, author name and price of History type If the file content is as follows:
books. INDIA is my country. I live in India. India has many states.
(ii) To increase the price of all history books by Rs 150. The countVowel() function should display the output as:
(iii) Show the details of all books in descending order of their Total number of vowels are : 20
prices. 30 A list contains the following record of a student: 3
28 Write the output of the queries (i) to (vi) based on the table given 3 [StudentName, Class, Section, MobileNumber]
below: TABLE: CHIPS Write the following user-defined functions to perform given
BRAND_NAME FLAVOUR PRICE QUANTITY operations on the stack named ‘xiia’:
LAYS ONION 10 5 (i) pushElement() - To Push an object containing the name and
LAYS TOMATO 20 12 mobile number of students who belong to class xii and section ‘a’
UNCLE CHIPS SPICY 12 10 to the stack
(ii) popElement() - To Pop the objects from the stack and display
UNCLE CHIPS PUDINA 10 12 them. Also, display “Stack Empty” when there are no elements in
HALDIRAM SALTY 10 20 the stack.
HALDIRAM TOMATO 25 30 For example: If the lists of students details are:
i) Select BRAND_NAME, FLAVOUR from CHIPS where PRICE >15; [“Rajveer”, “99999999999”,”XI”, “B”] [“Swatantra”,
(ii)Select * from CHIPS where FLAVOUR=”TOMATO” and PRICE<> “8888888888”,”XII”, “A”] [“Sajal”,”77777777777”,”VIII”,”A”]
20; [“Yash”, “1010101010”,”XII”,”A”]
(iii) Select BRAND_NAME from CHIPS where price > 15 and The stack “xiia” should contain
QUANTITY < 15; [“Swatantra”, “8888888888”]
(iv) Select count( distinct (FLAVOUR)) from CHIPS; [“Yash”, “1010101010”]
(v) Select price , price *1.5 from CHIPS where FLAVOUR = The output should be:
“PUDINA”; [“Yash”, “1010101010”]
(vi) Select distinct (BRAND_NAME) from CHIPS order by [“Swatantra”, “8888888888”]
BRAND_NAME desc; Stack Empty
Page 3 of 5
SECTION - D 3x5=15 Statement-4.
31 Rohit, a student of class 12th, is learning CSV File Module in 5 a) 'ROLL_NO', 'NAME', 'CLASS', 'SECTION'
Python. During the examination, he was assigned an incomplete b) roll_no,name,Class,section
Python code (shown below) to create a CSV File 'Student.csv' c) 'roll_no','name','Class','section'
(content shown below). Help him in completing the code which d) ROLL_NO, NAME, CLASS, SECTION
creates the desired CSV File. 5. Choose the function name that should be used in the blank
CSV File space of line marked as Statement-5 to create the desired CSV
1,AKSHAY,XII,A File.
2,ABHISHEK,XII,A a) dump() b) load() c) writerow() d) writerows()
3,ARVIND,XII,A 32 i) Explain all the database constraints? 2
4,RAVI,XII,A ii) Shabir wants to write a program in Python to insert the following +
5,ASHISH,XII,A record in the table named Student in the MYSQL database, 3
Incomplete Code: SCHOOL:
import_____ #Statement-1 rno(Roll number )- integer
fh = open(_____, _____, newline='') #Statement-2 name(Name) - string
stuwriter = csv._____ #Statement-3 DOB (Date of birth) – Date
data = [] Fee – float
header = ['ROLL_NO', 'NAME', 'CLASS', 'SECTION'] Note the following to establish connectivity between Python and
data.append(header) MySQL:
for i in range(5): Username - root
roll_no = int(input("Enter Roll Number : ")) Password - tiger
name = input("Enter Name : ") Host - localhost
Class = input("Enter Class : ") The values of fields rno, name, DOB and fee has to be accepted
section = input("Enter Section : ") from the user. Help Shabir to write the program in Python.
rec = [_____] #Statement-4 33 Alam has a list containing 10 integers. You need to help him create 5
data.append(rec) a program with separate user-defined functions to perform the
stuwriter. _____ (data) #Statement-5 following operations based on this list.
fh.close( ) Traverse the content of the list and push the even numbers into a
1. Identify the suitable code for the blank space in the line marked stack.
as Statement-1. Pop and display the content of the stack.
a) csv file b) CSV c) csv d) Csv For Example:
2. Identify the missing code for the blank space in the line marked If the sample Content of the list is as follows:
as Statement-2? N=[12, 13, 34, 56, 21, 79, 98, 22, 35, 38]
a) "School.csv","w" b) "Student.csv","w" Sample Output of the code should be:
c) "Student.csv","r" d) "School.csv","r" [38, 22, 98, 56, 34, 12]
3. Choose the function name (with argument) that should be used [13, 21, 79, 35]
in the blank space of the line marked as Statement-3 SECTION - E 2x4=8
a) reader(fh) b) reader(MyFile) c) writer(fh) d) writer(MyFile) 34 Consider the following tables ITEM and CUSTOMER. Write SQL 4
4. Identify the suitable code for blank space in line marked as queries for the following statements.
Page 4 of 5
Table: ITEM
I_ID Item_name Manufacturer Price
PC01 Personal Computer ABC 35000
LC05 Laptop ABC 55000
PC03 Personal Computer XYZ 32000
PC06 Personal Computer COMP 37000
LC03 Laptop PQR 57000
Table: CUSTOMER
C_ID Cx_Name City I_ID
01 N Roy Delhi LC03
06 H Singh Mumbai PC03
12 R Pandey Delhi PC06
15 C Sharma Delhi LC03
16 K Agarwal Bangalore PC01
i) To display the details of these customers whose city is Mumbai.
ii) To display the details of items whose Price is in the range of
35000 to 60000 (Both values included).
iii) To display the Cx_Name, City from table Customer and
Item_Name and Price from table ITEM, with their corresponding
matching I_ID.
iv) To increase the Price of all items by 1500 in the table ITEM.
35 Write a Program in Python that defines and calls the following user- 4
defined functions:
(i) ADD( ) – To accept and add data of a teacher to a CSV file
‘teacher.csv’. Each record consists of a list with field elements as
tid, name and mobile to store teacher id, teacher name and
teacher mobile number respectively.
(ii) COUNTR( ) – To count the number of records present in the CSV
file named ‘teacher.csv’.
*******************
Page 5 of 5