0% found this document useful (0 votes)
28 views5 pages

12 Iit Subjective-1 QP

The document is an examination paper for Class XII in Computer Science, consisting of multiple sections with a variety of questions including code evaluation, output prediction, and function writing. It covers topics such as Python programming concepts, data structures, and error handling. The paper is structured into three sections with a total of 40 marks, testing students' understanding and application of programming skills.

Uploaded by

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

12 Iit Subjective-1 QP

The document is an examination paper for Class XII in Computer Science, consisting of multiple sections with a variety of questions including code evaluation, output prediction, and function writing. It covers topics such as Python programming concepts, data structures, and error handling. The paper is structured into three sections with a total of 40 marks, testing students' understanding and application of programming skills.

Uploaded by

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

SAGAR INTERNATIONAL SCHOOL, PERUNDURAI.

AFFILIATED NO: 1930419


SUBJECTIVE – I (APRIL’25)
CLASS: XII–IIT MARKS:40
DATE : SUBJECT:CS TIME :1½Hrs.
SECTION – A 18 * 1 = 18
1. Evaluate the following expression:
print(not 3 < 5 < 10 == 10 and 5>2 or False)
2. Predict the output for the following code:
text='gmail@com'
L=len(text)
ntext=''
for i in range(0,L):
if text[i].isupper():
ntext=ntext+text[i].lower()
elif text[i].isalpha():
ntext=ntext+text[i].upper()
else:
ntext=ntext+'bb'
print(ntext)
3. Predict the output for the following piece of code:
aLst={‘a’:1,’b’:2,’c’:3}
print(aLst[‘a’,’b’])
4. Predict the output for the following code:
list1 = [1998, 2002, 1997, 2000]
list2 , list3= list1.copy() , list1
list1[2], list2[2], list3[1]=2001, 2002, 2003
print(list1,list2,list3,sep="\n",end="$")
5. What is the output when the following code is executed?
L=[23,34,65,32,3]
L.insert(L[4],'Monitor')
print(L)
a. [23, 45, 65, ‘Monitor’, 32, 3] b. [23, 34, 65, 32, ‘Monitor’, 3]
c. [23, 34, 65, 32, 3, ‘Monitor’] d. [23, 34, 65, 'Monitor', 32, 3]
6. What will be the output of the following python code:
print(“abef”.partition(“cd”))
a. (“abef”) b. (“abef”,”cd”,””)
c. (“abef”,””,””) d. error
7. What is the output for the following piece of code:
L1 = ['C++', 'C-Sharp', 'Visual Basic']
L2 = [name.upper( ) for name in L1]
L3 = [name for name in L1]
if (L2[2][0] == L3[2][0]):
print("yes")
else:
print("no")
a. no b. yes c. error d. none of the above
8. Which of the following statement(s) would correctly replace the
else statement?
def comparing_lengths(lst1, lst2):
if len(lst1) > len(lst2):
return "The length of lst1 is greater than the length of lst1"
elif len(lst1) < len(lst2):
return "The length of lst2 is greater than the length of lst1"
else:
return "The length of lst1 and the length of lst2 are equal"
A. elif len(lst1) = len(lst2):
B. elif len(lst1) == len(lst2):
C. elif not(len(lst1) > len(lst2)) and not(len(lst1) < len(lst2))
D. elif not(len(lst1) > len(lst2)) or not(len(lst1) < len(lst2))
E. elif not(len(lst1) is not len(lst2)):
9. What will be the output of the following python code:
print(“xyyzxxyxyy”.strip(“xyy”))
a. error b. zxxyxyy c. z d. zxxy
10. Which of the statements about dicitonary values is false?
a. more than one key can have same value
b. the values of the dictionary can be accesses as dict[key]
c. values of a dictionary must be unique
d. values of a dictionary can be a mixture of letters and numbers
11. What will be the output of the following python code:
my_tuple = (1, 2, 3, 4)
my_tuple . append( (5,6,7) )
print( len(my_tuple))
12. What is the purpose of the finally block in Python error handling?
a) To handle exceptions
b) To raise exceptions
c) To ensure that certain code will always be executed
d) To terminate the program
13. How can you handle multiple exceptions in a single except block?
a) Separate the exceptions using commas in except statement
b) Use nested except blocks
c) Use the except keyword only once
d) It is not possible to handle multiple exceptions in a single except
block
14. Assertion (A): Some of the real-life applications of random module
include CAPTCHA, OTP generation, automatic password
generator and auto-filling, etc.
Reasoning (R): To import a random module, use:
import random
from random import*
a) Both A and R are True and R expains A
b) Both A and R are True and R doesnot expains A
c) A is True but R is False
d) A is False but R is True
e) Both are False

SECTION - B 7 * 2 =14
15. def FindOutput( ):
L= "learn"
X=''
L1=[]
count=1
for i in L:
if i in ['a','e','i','o','u']:
X=X+i.swapcase()
else:
if count%2!=0:
X=X+str(len(L[:count]))
else:
X=X+i
count=count+1
print(X)
FindOutput( )
16. Write a function that accepts file name and length of word, n as
input. The function counts and display the number of n letter words.
Sample Input:
File name : Sample.txt
Word length : 5
17. Write a function in python to get a string and ‘k’ as input and
replace every kth character by ‘_’.
Sample input:
String : TELEVISION
K:3
Expected output:
TE_EV_SI_N
18. What possible output(s) are expected to be displayed on the
screen at the time of execution of the following program. Also, write
the maximum and minimum value for the variables f, s, t.
import random as r
M = (5, 10, 15, 20, 25, 30)
for i in range (1, 3):
f=r.randint(2,5)-1
s=r.randint(3,6)-2
t=r.randint(1,4)
print(M[f], M[s], M[t], sep="#")
a) 10#25#15# b) 5#25#20#
20#25#25# 25#20#15#
c) 30#20#20# d) 10#15#25#
20#25#25# 15#20#10#
19. What is the difference between actual and formal parameters?
20. Explain LEGB Rule with example.
21. Find the errors and correct the code. Also, underline the
corrections made.
STRING= "WELCOME"
NOTE=" "
for S in range (0, 8) :
print (STRING [S])

SECTION – C 4 * 3 = 12
22. Write a function in python to read the contents of the file and print
the words that does not have vowels in them. Also print the number
of words doesn’t have vowels.
23. Write a function in python to read the contents of the file
“grammar.txt” and print all the words in lexicographical order.
Note: don’t use max(), min(), sorted(), sort() functions
24. Write a function filter(oldfile, newfile) that copies all the lines of a
text file “source.txt” onto “target.txt” except those lines which starts
with “@” sign. In case if the file is not found, use exception
handling mechanism to handle the Exception and print a message
“File is not in the current location”.
25. You have a stack named BooksStack that contains records of
books. Each book record is represented as a list
containing book_title, author_name, and publication_year. Write
the following user-defined functions in Python to perform the
specified operations on the stack BooksStack:

push_book(BooksStack, new_book): This function takes the stack


BooksStack and a new book record new_book as arguments and
pushes the new book record onto the stack.

pop_book(BooksStack): This function pops the topmost book


record from the stack and returns it. If the stack is already empty,
the function should display "Underflow".

peep(BookStack): This function displays the topmost element of


the stack without deleting it. If the stack is empty, the function
should display 'None'.

You might also like