Professional Documents
Culture Documents
Xii First Term Question Computerscience 21-22
Xii First Term Question Computerscience 21-22
Xii First Term Question Computerscience 21-22
Part – A
Section – I
Attempt any 7 questions from question no 1 to 13.
1. Suppose t=(1,2,4,3), which of the following is incorrect? 1
(i) print(t[3])
(ii) t[3]=45
(iii) print(max[t])
(iv) print(len(t))
2. Out of the following, find the identifiers, which cannot be used for 1
naming Variable or Functions in a Python program:
2 _Cost, switch, Address one, Delete, Number12
Page 1 of 6
3. Find and write the output of the following code: 1
for name in ['Aryan','Sarun']:
if name[0]=='S':
print(name)
print("Got it")
break
else:
print("Finished")
5. Write a Python Dictionary named Dct with 10 keys 0…9, each having 1
values as 500.
6. Which statement is used to retrieve the current position within the file? 1
(i) fp.seek() (ii) fp.tell() (iii) fp.loc (iv) fp.pos
8. Which is the correct command to load just the tempc method from a 1
module called usable?
a) import usable,tempc
b) import tempc from usable
c) from usable import tempc
d) import tempc
9. How many times is the following loop executed? 1
i = 100
while (i<=200):
print (i)
i + =20
10. Find and write the output of the following python code: 1
a=10
def call():
global a
a=15
b=20
print(a)
call()
Page 2 of 6
11. What is the output produced by the following code – 1
d1={5:[6,7,8],”a”:(1,2,3)}
print(d1.keys())
print(d1.values())
12. Give the name of the required module for the given functions? 1
(i) mean() (ii)sin()
Section-II
Both the case study-based questions are compulsory. Attempt any 4
sub parts from each question .Each question carries 1 mark.
Page 3 of 6
15. Mustafa is preparing for his board exams. He is confused with some
terms related to function. Help him to find the suitable term for the
following descriptions.
a) A variable created inside a function body. 1
b) A value passed to a function parameter. 1
c) An argument passed to a specific parameter using the parameter 1
name.
d) A value assigned to a parameter name in the function header. 1
e) A name defined outside all function definitions. 1
Part-B
Section-I
16. Explain the use of pass statement with an example. 2
OR
def work(x,y=30) :
x= x+y/y
print(x)
z=str(y+x)
y=str(y)
if z.isalnum():
return z+"*"+y
else:
return False
w=work(25)
print(w)
OR
19. Convert the for loop into while loop:
for i in range(100):
if i % 2 == 0:
print(i, "is even")
else :
print(i, "is odd")
25. Write a user-defined function named Count() that will read the contents 3
of text file named "Report.txt" and count the number of lines which start
with either "I" or "M" and display the count. E.g., In the following
paragraph, there are 2 lines starting with "I" or "M":
“India is the fastest growing economy.
India is looking for more investments around the globe.
The whole world is looking at India as a great market.
Most of the Indians can foresee the heights that India is capable of
reaching."
Page 5 of 6
OR
26. Write a function in Python that counts the number of “I” or “you”
words present in a text file “APOLOGIZE.TXT”. If the
“APOLOGIZE.TXT” contents are as follows:
" I am sorry about the mean thing I said to you ."
" I am sorry I lost your book ."
" I was mad, but I shouldn't have called you a name .
I am sorry."
" I am sorry I hurt your feelings ."
" I am sorry I yelled at you ."
The output of the function should be: Count of I/you in file: 14
Page 6 of 6