0% found this document useful (0 votes)
394 views7 pages

XIIComp SC Term1431

The document is the question paper for the Computer Science exam of class XII students of Al Alia International Indian School, Riyadh. It contains instructions for the exam and questions divided into 5 sections (Section A to E). Section A contains 18 multiple choice questions carrying 1 mark each. Section B contains 7 very short answer questions carrying 2 marks each. Section C contains 5 short answer questions carrying 3 marks each. Section D contains 3 long answer questions carrying 5 marks each. Section E contains 2 questions carrying 4 marks each. All programming questions are to be answered using Python language only.

Uploaded by

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

XIIComp SC Term1431

The document is the question paper for the Computer Science exam of class XII students of Al Alia International Indian School, Riyadh. It contains instructions for the exam and questions divided into 5 sections (Section A to E). Section A contains 18 multiple choice questions carrying 1 mark each. Section B contains 7 very short answer questions carrying 2 marks each. Section C contains 5 short answer questions carrying 3 marks each. Section D contains 3 long answer questions carrying 5 marks each. Section E contains 2 questions carrying 4 marks each. All programming questions are to be answered using Python language only.

Uploaded by

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

Al Alia International Indian School, Riyadh

Online Examination, July – 2023


Computer Science
Class : XII Max Marks : 70
Date : 19/07/2023 Duration : 3 Hrs.
General Instructions:
1. This question paper contains five sections, Section A to E.
2. All questions are compulsory.
3. Section A has 18 questions carrying 01 mark each.
4. Section B has 07 Very Short Answer type questions carrying 02 marks each.
5. Section C has 05 Short Answer type questions carrying 03 marks each.
6. Section D has 03 Long Answer type questions carrying 05 marks each.
7. Section E has 02 questions carrying 04 marks each.
8. All programming questions are to be answered using Python language only.

SECTION A

1. State True or False 1


“Python has a set of keywords that can also be used to declare variables”.

2. In a Python program, control structure : 1


a) defines program specific data structure
b) directs the order of execution of statement in the program
c) dictates what happened before the program starts and after it terminates
d) none of the above

3. Which type of error occurs when rules of programming language are misused? 1
a) index setup
b) semantic error
c) runtime error
d) logical error
4. Choose the correct output of the following Python code: 1
def ChangeList():
l=[]
l1=[]
l2=[]
for I in range(1,10):
l.append(i)
for i in range(0,1,-2):
l1.append(i)
for i in range (len(l1)):
l2.append(l1[i]+l[i])
l2.append(len(l)-len(l1))
print(l2)
ChangeList()
a) [11,10,9,8,7,4]
b) [11,10,9,8,7,6]
c) [11,10,9,8,7]
d) [10,9,8,7,6,5
5. Which output is not expected from the following program: 1
import random
X=3
N=random.randint(1,x)
for i in range(N):
print (I,”#”,i+1)
a)0#1
b)1#2
c)2#3
d)3#4
6. If a function doesn’t have a return statement, which of the following does the function return? 1
a) int
b) null
c) None
d) An exception is thrown without the return statement

7. Select the correct output of the following python code: 1


str="My program is program for you"
t = str.partition("program")
print(t)
a) ('My ', 'program', ' is ', 'program', ' for you')
b) ('My ', 'program', ' is program for you')
c) ('My ', ' is program for you')
d) ('My ', ' is ', ' for you')

8. Which of the file opening mode will open the file for reading and writing in 1
binary mode.
a) rb b) rb+ c) wb d) a+
9. The pickle module in Python is used for: 1
(a) Serializing any Python object structure
(b) De-serializing Python object structure
(c) Both a and b
(d) None of these

10. How are default arguments specified in the function heading? 1


a. identifier followed by an equal to sign and the default value
b. identifier followed by the default value within backticks (“)
c. identifier followed by the default value within square brackets ([])
d. identifier
11. What will be the output of the following code? 1
D1={1: “One”,2: “Two”, 3: “C”}
D2={4: “Four”,5: “Five”}
D1.update(D2)
print (D1)
a) {4:’Four’,5: ‘Five’}
b) Method update() doesn’t exist for dictionary
c) {1: “One”,2: “Two”, 3: “C”}
d) {1: “One”,2: “Two”, 3: “C”,4: ‘Four’,5: ‘Five’}
12. How many times will the following code be executed 1
for i in range(1,15,5):
print(i,end=’,’)
a) 3
b) 4
c) 1
d) infinite
13. Which of the following Statement(s) would give an error after executing the 1
following code?
d={"A":1, "B": 2, "C":3, "D":4} #Statement 1
sum_keys =0 #Statement 2
for val in d.keys(): #Statement 3
sum_keys=sum_keys+ val #Statement 4
print(sum_keys)
a) Statement 2
b) Statement 4
c) Statement 1
d) Statement 3
14. Which of the following python statement will bring the read pointer to 10th character from the 1
end of a file containing 100 characters, opened for reading in binary mode.
a) File.seek(10,0)
b) File.seek(-10,2)
c) File.seek(-10,1)
d) File.seek(10,2)
15. Select the correct output of the code: 1
a= "Year 2023 at All the best"
a = a.split('2')
a = a[0] + ". " + a[1] + ". " + a[3]
print (b)
(a) Year . 0. at All the best (b) Year 0. at All the best
(c) Year . 023. at All the best (d) Year . 0. at all the best
16. What will be the output of the following python code: 1
val = 100
def display(N):
global val
val = 50
if N%14==0:
val = val + N
else:
val = val - N
print(val, end="@")
display(40)
print(val)
a)100@10
b) 50@5
c) 5@50
d)100@10@
Q17 and Q18 are ASSERTION AND REASONING based questions. Mark the correct choice as:
i. Both A and R are true and R is the correct explanation for A
ii. Both A and R are true but R is not the correct explanation for A
iii. A is True but R is False
iv. A is false but R is True
17. Assertion (A): - If the arguments in a function call statement match the number and order of 1
arguments as defined in the function definition, such arguments are called positional arguments.

Reasoning (R): - During a function call, the argument list first contains default argument(s)
followed by positional argument(s).
18. Assertion (A): A binary file stores the data in the same way as as stored in the memory. 1

Reasoning (R): Binary file in python does not have line delimiter.
SECTION B
19. Predict the output of the python code given below: 2
st= "python programming"
count=4
while True:
if st=="p":
st=st[2:]
elif st[-2]=="n":
st =st[:4]
else:
count+=1
break
print(st)
print(count)

20. What are arguments? What are Parameters? How are these two terms different yet related? 2
Give example.
21. Rewrite the following code in python after removing all the syntax errors. Underline each 2
correction done in the code.
num1, num2 = 10
While num1 % num2 = 0
num1+= 20
num2+= 30
Else:
print(‘hello’)
print(‘hello’)

22. Write a function which accepts the two list and returns a list having only those elements that 2
are common between both the list (without duplicates) in ascending order make sure your
program works on two list of different sizes.
example
L1 =[1,1,2,3, 5, 8, 13, 21, 34, 55, 89]
L2 =[1,2,3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]

OR
Write a user defined function countwords () to accept a sentence from console and display the
total number of words present in that sentence.
For example: if the sentence entered by the user is
“ living a life you can be proud of doing your best “ then the countwords( ) function should
display the word as
Total number of words =11
23. Predict the output of the following Code: 2
for i in range(-10,0):
if i%3==0:
print(i,end=' ')
print(i**2)
OR
What is the output of the following code segment :
fruits={}
dresses={}
toys={}
fruits[1]=”mango”
fruits[2]=”papaya”
dresses[3]=”frock”
toys[‘Fruits’]=fruits
toys[‘Dresses’]=dresses
print(toys)
24. Write the output of the following Python program code: 2
TXT = ["10","20","30","5"]
CNT = 3
TOTAL = 0
for C in [7,5,4,6]:
T = TXT[CNT]
TOTAL = float (T) + C
print (TOTAL)
CNT-=1
25. (a) Given is a Python string declaration: 2
Word = "Connect Python”
Write the output of: print(Word[: : 3])
(b) Write the output of the code given below:
dict = {"Item": "Laptop", "Make": "LG" }
dict["Price"] = 57000
dict["Make"] = "DELL"
for k in dict:
print(k, ‘@’, dict[k])
SECTION C
26. Write a function INDEX_LIST(L), where L is the list of elements passed as argument to 3
the function. The function returns sum of odd nos in list .
OR
Write a function REP which accepts a list of integers and size of list and replaces elements
having even values with its half and elements having odd values with twice its value.
eg: if the list contains
[3, 4, 5, 16, 9]
then the function should return rearranged list as
[6, 2,10,8, 18]
27. Write a function in Python that counts the number of “the” or “this” words 3
present in a text file “myfile.txt”.
Example: If the “myfile.txt” contents are as follows:
This is my first class on Computer Science. File handling is the easiest topic for
me and Computer Networking is the most interesting one.
The output of the function should be: Count of the/this in file: 3
28. Find and write the output of the following Python code: 3
def Show(str):
m=""
for i in range(0,len(str)):
if(str[i].isupper()):
m=m+str[i].lower()
elif str[i].islower():
m=m+str[i].upper()
else:
if i%2==0:
m=m+str[i-1]
else:
m=m+"#"
print(m)
Show('HappyBirthday')
29. a. What is the meaning of return value of a function? Give an example to illustrate its meaning. 3
b. Differentiate between call by value and call by reference with a suitable example for each.

30. Differentiate between Positional Argument and Default Argument of function in python with 3
suitable example.
SECTION D

31. Consider the following string and answer the given questions: 5
(1+1+1+
str1= “Competency based Education‟
2)
Write the output:
a) print(str1[len(str1)-1]+'India'+str1[-7:-2])
b) print(str1[len(str1[2:6]):len(str1[3:10])].lower())
c) print(str1.split('based'))
d) Write python code to print each word of the str1 in separate line.
32. A binary file “Toy.dat” has structure [TID, Toy, Status, MRP]. 5
i. Write a user defined function CreateFile() to input data for a record and add to Toy.dat.
ii. Write a function OnOffer() in Python to display the detail of those Toys, which has status as
“ON OFFER” from Toy.dat file.
33. a) What is the advantage of using a csv file for permanent storage? 5
b) Write a Program in Python that defines and calls the following userdefined functions:
(i) ADD() – To accept and add data of an employee to a CSV file
‘record.csv’. Each record consists of a list with field elements as
empid, name and mobileto store employee id, employeename and
employee salary respectively.
(ii) COUNTR() – To count the number of records present in the CSVfile
named ‘record.csv’.
OR
Give any one point of difference between a binary file and a csv file.Write a Program in Python
that defines and calls the following user defined functions:
(i) add() – To accept and add data of an employee to a CSV file‘furdata.csv’. Each record
consists of a list with fieldelements as fid, fname and fpriceto store furnitureid, furniture name
and furniture price respectively.
(ii) search()- To display the records of the furniture whoseprice is more than 10000.
SECTION E
34. A binary file “STUDENT.DAT” has structure [admission_number, Name, Percentage]. Write a 4
function countrec() in Python that would read contents of the file “STUDENT.DAT” and
display the details of those students whose percentage is above 75. Also display number of
students scoring above 75%.
35. Write a Program in Python that defines and calls the following user defined functions: 4
i) A csv file "PATIENTS.csv" has structure [PID, NAME, DISEASE].
ii) Write the definition of a function countrec() in Python that would read contents of the
file "PATIENTS.csv" and display the details of those patients who have the DISEASE as
'COVID-19'. The function should also display the total number of such patients whose DISEASE
is 'COVID-19'

You might also like