Xii First Term Question Computerscience 21-22

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

DPS – MODERN INDIAN SCHOOL, DOHA- QATAR

FIRST TERM EXAMINATION (2021 –22)


CLASS: XII

Subject: COMPUTER SCIENCE Date: 06.06.2021


Time allowed: 1Hour 30 Minutes. Maximum Marks: 50
General instructions:
1. This question paper contains two parts A and B. Each part is compulsory.
2. Both Part A and Part B have choices.
3. Part-A has 2 sections:
a. Section – I is short answer questions, to be answered in one word or one line.
b. Section – II has two case studies questions. Each case study has 5 case-based
subparts. An examinee is to attempt any 4 out of the 5 subparts.
4. Part - B is Descriptive Paper.
5. Part- B has three sections.
a. Section-I is short answer questions of 2 marks each in which two question
have internal options.
b. Section-II is long answer questions of 3 marks each in which two questions
have internal options.
c. Section-III is very long answer questions of 5 marks each in which one
question has internal option.
6. All programming questions are to be answered using Python Language only.

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")

4. Predict the output: 1


>>>S1=’Hello brother’
>>>S1=S1[-4:]
>>>print(S1*2)

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

7. The smallest individual unit in a program is known as __________. 1

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()

13. In recursive function ________case must always be reachable 1

Section-II
Both the case study-based questions are compulsory. Attempt any 4
sub parts from each question .Each question carries 1 mark.

14. Suresh of class 12 is writing a program to create a CSV file “student.csv”


which will contain Name, Date of Birth, and place. He has written the
following code. As a programmer, help him to successfully execute the
given task.
import #Line 1
with open('student.csv', ,newline=' ') as f: #Line 2
w = csv. (f) #Line 3
ans= 'y'
while (ans== 'y'):
name= input("Name: ")
date = input("Date of birth: ")
place = input("Place: ")
w.writerow([name, date, place])
ans=input("Do you want to enter more y/n? ")
F=open("student.csv", 'r')
reader = csv. (F) #Line 4
for row in reader:
print(row)
F. #Line 5
a) Name the module he should import in Line 1. 1
b) In which mode in Line 2, Suresh should open the file to add data into 1
the file.
c) Fill in the blank in Line 3 to write the data to the csv file. 1
d) Fill in the blank in Line 4 to read the data from a csv file. 1
e) Fill in the blank in Line 5 to close the file. 1

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

17. Predict the output of the following code

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)

18. What is the difference between “w” and “a” modes ? 2

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")

20. What is a package? How is a package different from a module? 2


Page 4 of 6
21. What possible output(s) are expected to be displayed on screen at the 2
time of execution of the program from the following code? Also
specify the maximum values that can be assigned to each of the
variables start and end.
import random
H=[45.0,86.5,32.1,100.5]
start=random.randint(1,4)
end=random.randrange(0,len(H))
for I in range(start,end):
print (H[I],end="#")
(i) 86.5#32.1# (ii) 45.0#86.5#32.1# (iii) 32.1# (iv) 32.1#100.5#
Section- II
22. The following function magicfunc() is a part of a program. What will be 3
the function return when the value of n=10? Show the working.
def magicfunc(n):
if n==0:
return 0
else:
return magicfunc(n//2)*10 +(n%2)
OR
23. Find and write the output of the following python code:
def Change(P ,Q=4):
P=P*Q
Q=P//Q
print( P,"@",Q)
return (P)
R=20
S=10
R=Change(R,S)
print(R,"&",S)
S=Change(S)

24. Write a program to print a Fibonacci series of n terms using recursion. 3

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

27. Write the definition of a method SquareSum(Num) to find sum of 3


squares of every third element in the list of numbers and display the
sum.
Section-III
28. Write a program using function that takes 2 numbers and returns the 5
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)?
29. A binary file “EMP.DAT” has structure (Emp_Id, Name, Salary). Write a 5
function Update() in Python that would read the contents of the file
“EMP.DAT” and update the salary of the employee whose Emp_Id is
1005, with a new salary.
OR
30. Write a function to search and display details of all trains, whose
destination is “Delhi” from a binary file “TRAIN.DAT”. Assuming the
binary file is containing the objects of the following dictionary type:
Train={‘Tno’:---------,’From’:-----------,’To’:--------------}

31. Consider the following CSV file (Employee.csv): 5


1001,Patrick,25000
1002,Tom,32000
1003,Harry,35000
1004,Michael,75000
1005,Tamara,45900
Write a Python function TNAMES() to read the content of file
Employee.csv and display the employee record whose name begins
with “T”. Also show no. of employee with first letter “T” out of total
record.
************************

Page 6 of 6

You might also like