12 CS - S2 KVP
12 CS - S2 KVP
General Instructions:
● This question paper contains 37 questions.
● All questions are compulsory. However, internal choices have been provided in some
questions. Attempt only one of the choices in such questions
● The paper is divided into 5 Sections- A, B, C, D and E.
● Section A consists of 21 questions (1 to 21). Each question carries 1 Mark.
● Section B consists of 7 questions (22 to 28). Each question carries 2 Marks.
● Section C consists of 3 questions (29 to 31). Each question carries 3 Marks.
● Section D consists of 4 questions (32 to 35). Each question carries 4 Marks.
● Section E consists of 2 questions (36 to 37). Each question carries 5 Marks.
● All programming questions are to be answered using Python Language only.
● In case of MCQ, text of the correct answer should also be written.
The data type of a variable in Python can be modified during the execution of the
1
1 program.
Select the correct output of the code:
s="GOOD MORNing"
print(s.capitalize(),s.title(),s.swapcase(),end="!")
a) Good morning Good Morning good MORNing!
b) Good morning Good Morning good mornING
c) Good morning! Good Morning! good mornING!
d) Good morning Good Morning good mornING!
2 1
What will the output of the following expression in Python?
print(2**3**2//8)
(a)64.0 (b)64 (c)8 (d)None Of These
3 1
What will be the output for the following Python statement?
D1={'Rahul':295, 'Rithu':15, 'Mishel':64, 'Nihan':120}
print('Mishel' in D1, 15 in D1, sep="#")
(a)True#False (b) True#True
(c) False#True (d) False#False
4 1
Select the correct output of the code:
Str="I will Succeed"
lis=Str.split(" ")
print(lis[-1])
(a) I
(b) will
(c) Succeed
(d) ”I will Succeed”
5 1
Select the correct output of the code:
Str= "INCREDIBLE INDIA @ 75"
S=Str.partition(" ")
print(S)
a. (@ 75' 'INCREDIBLE', ' ', 'INDIA,)
b. ('INCREDIBLE', ' @', 'INDIA , 75')
c. ('', ' ', 'INCREDIBLE INDIA @ 75')
d. ('INCREDIBLE', ' ', 'INDIA @ 75')
6 1
Which one of the following is the function to get list of keys from a dictionary
dict in python?
a. dict.getkeys()
b. dict.getvalues()
c. dict.keys()
d. None Of These
7 1
What is the correct way to add an element to the end of a list in Python?
a. list.add(element)
8 b. list.append(element) 1
c. list.insert(element)
d. list.extend(element)
1
20 Assertion(A): A function is block of organized and reusable code that is used to
perform a single, related action.
Reasoning(R): Function provides better modularity for your application and a high
degree of code reusability.
(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
1
21 Assertion(A) : Delete command is used to remove rows or records from table.
Reason(B) : This command is used to remove records along with structure of the
table from database
(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
1
Section-B ( 7 x 2=14 Marks)
Write a suitable Python statement for each of the following tasks
using built-in functions/methods only:
i To delete an element ‘Apple’:100 from Dictionary Fruits.
ii To display words in a string S in the form of a list
22 2
What will be the out put of the following code
L = [10,15,20,25]
G = 10
def Change(X):
global G
N=len(X)
for i in range(N):
X[i] += G
Change(L)
for i in L:
23 print(i,end='@') 2
What will be the output of the following code?
L=["Sunday" , "Monday", "Tuesday", "Wednesday"]
print(len(L)/2*len(L[2]))
24 2
What possible outputs(s) will be obtained when the following code is executed?
import random
Signal=['Stop','Wait','Go']
for K in range (2,0,-1):
R=random.randrange(K)
print(Signal[R], end='#')
a. Stop#Go#
b. Wait#Stop#
c. Go#Stop#
d. Go#Wait#
25 2
In the python code given below is not giving the expected output . There are some
errors in it. Rewrite the correct code and underline the corrections made.
DEF execmain():
x = input(“Enter a number ”;)
if (abs(x)=x):
print (“You entered a positive number”)
else:
x=*-1
print (“Number made positive :”)
execmain()
26 2
What is a NOT NULL constraint in SQL? Give example to illustrate.
OR
Section-C ( 3 x 3 = 9 Marks)
Write a function in python to count the number lines in a text file ‘Woods.txt’ which 3
is starting with an alphabet ‘W’ or ‘H’. If the file contents are as follows:
The countwords() function should display the output as: Total number of words : 40
29
A list contains following record of a customer: 3
[Customer_name, Phone_number, City]
Write the following user defined functions to perform given operationson the stack
named ‘status’:
(i) Push_element() - To Push an object containing name and Phone number of
customers who live in DELHI 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 the stack.
(iii)Top_element() This function displays the topmost element of the stack without
deleting it. If the stack is empty, the function should display 'None'.
30 For example:
If the lists of customer details are:
[“AJEY”, “5588996633”,”DELHI”]
[“AMITH”, “9988776633”,”CHENNAI”]
[“MINU”,”7799664488”,”BENGALURU”]
[“ROHAN”, “8899446622”,”DELHI”]
[“AJEY”, “5588996633”,”DELHI”]
3
Predict the output of the Python code given below:
L=[1,2,3,4,5]
Lst=[]
for i in range(len(L)):
if i%2==1:
t=(L[i],L[i]**2)
Lst.append(t)
print(Lst)
OR
Table: STAFF
EID Name DOB DOJ Salary Grade
(ii) search()- To display the records of the toys whose price is more than
500.
33
Write SQL queries for (i) to (iv) based on the tables PASSENGER and FLIGHT 4
given below:
Table: PASSENGER
PNO NAME GENDER FNO
1001 Suresh MALE F101
1002 Anita FEMALE F104
1003 Harris MALE F102
1004 Nita FEMALE F103
34
Table: FLIGHT
FNO START END F_DATE FARE
F101 MUMBAI CHENNAI 2021-12-25 4500
F102 MUMBAI BENGALURU 2021-11-20 4000
F103 DELHI CHENNAI 2021-12-10 5500
F104 KOLKATA MUMBAI 2021-12-20 4500
F105 DELHI BENGALURU 2021-01-12 5000
iii) Write a query to delete the records of flights which ends at ”MUMBAI”.
Write the following Python function to perform the specified operation: Insert_Show():
To input details of an item and store it in the table EMPLOYEE. The function should
then retrieve and display all records from the EMPLOYEE table where the Salary is
greater than 50000. Assume the following for Python-Database connectivity: Host:
localhost, User: root, Password: 123
35
SECTION E (2 X 5 = 10 Marks)
i. Mention any two differences between binary files and csv files? 5
Indian School, in Delhi is starting up the network between its different wings. There 5
are Four Buildings named as SENIOR, JUNIOR, ADMIN and HOSTEL as shown
below:
And also they have a Cricket ground 2000 KM away from the school wing.
SENIOR 130
JUNIOR 80
ADMIN 160
HOSTEL 50
1) Suggest the cable layout of connections between the buildings and the
topology thus formed (school wings only).
2) Suggest the most suitable place (i.e. building) to house the server of this
school, provide a suitable reason.
5) Which fast and very effective wireless transmission medium should preferably
be used to connect the school wing at Delhi with the Cricket ground for live
Telecast?
*******************