0% found this document useful (0 votes)
91 views2 pages

12CS T1 2022 SetA

This document contains a 15 question exam on Python programming concepts like loops, data types, files and functions. The questions cover topics like identifying correct options, writing code to solve problems, giving outputs for code snippets, and writing functions to perform tasks like reading and writing to files.

Uploaded by

moiiifitbituser
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)
91 views2 pages

12CS T1 2022 SetA

This document contains a 15 question exam on Python programming concepts like loops, data types, files and functions. The questions cover topics like identifying correct options, writing code to solve problems, giving outputs for code snippets, and writing functions to perform tasks like reading and writing to files.

Uploaded by

moiiifitbituser
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/ 2

Fahaheel Al-Watanieh Indian Private School, Ahmadi, Kuwait

First Term Examination 2022-23 Set


Computer Science (083)
Class XII
A
Time: 2 Hours Maximum Marks: 35
1. Identify the correct options: [1]
a) A Python while-loop may not be nested
b) A Python for-loop must contain a range() function after in
c) A Python while-loop must contain an expression
d) A Python for-loop must contain an iterable object after in

2. Identify the correct options: [1]


a) Python data types int, float and str are immutable type
b) Python data types int, float and str are passed by value to a function
c) Python data types int, float and str are mutable type
d) Python data types int, float and str are passed by reference to a function

3. Identify the correct options: [1]


a) A tuple type object does not support negative index
b) A string type object supports negative index
c) A tuple type object supports negative index
d) A string type object does not support negative index

4. Identify the correct options: [1]


a) In a dictionary, key is immutable type and value can be immutable type
b) In a dictionary, key is immutable type and value can only be mutable type
c) In a dictionary, key is immutable type and value can be mutable type
d) In a dictionary, key is mutable type and value can only be immutable type

5. Identify the correct options: [1]


a) Using keyword with, a file object is required for any file operation
b) Using keyword with, a file can be opened without open()
c) Using keyword with, a file object is not required for any file operation
d) Using keyword with, a file is closed without close()

6. Identify the correct options: [1]


file=open('CLASS.DAT')
a) CLASS.DAT cannot be opened since mode is missing
b) CLASS.DAT is opened as a text file
c) CLASS.DAT is opened in read mode
d) CLASS.DAT is opened as a binary file

7. Identify the correct options: [1]


a) seek(0, 2) takes the file pointer to the end of the file
b) seek(2, 0) takes the file pointer to the end of the file
c) File pointer is positioned at the end of the file in append mode
d) File pointer is positioned at the beginning of the file in append mode

8. Rewrite the Python script after removing all the errors. Underline the corrections. [2]
myfile=open("SOCCER.TXT", rt)
mydata=read(myfile)
print(data)
mydata.close()
XII 1st Term Exam 2023-23 Set-A Page 1 / 2 Subject: Computer Science (083)
9. Give the output of the Python scripts given below: [2+3=5]
a) word='BRILLIANCE'
print(word[:5], word[5:])
print(word[::2], word[9::-2])

b) def pyfunc(a, b):


global c
a*=b
b+=b+c
c+=a+b+c
print(a, b, c)

x, y, c=2, 4, 5
pyfunc(x, c)
pyfunc(y, c)

10. Write any three differences between list type and tuple type. [3]

11. Write any two differences between local variable and global variable. [2]

12. Write a Python function to read and display a text file 'EIDBREAK.TXT'. At the end count and
display number of uppercase consonants present in the text file.
[3]

13. Write a Python function to read and display a text file 'EIDBREAK.TXT'. At the end count and
display number of words starting with a digit present in the text file.
[3]

14. A CSV data file 'STAFF.CSV' containing following data: code,name,sub,nop


code is integer, name is string, sub (subject) is string and nop (number of periods) is integer
a) Write a Python function to append n (n is a parameter to the function) records in the CSV data
file 'STAFF.CSV'. [3]

b) Write a Python function to read and display the CSV data file 'STAFF.CSV'. At the end display
number of records where sub is 'MATH' and nop<26. [4]

15. A binary data file 'HOUSE.DAT' storing student records where every record is a list containing
following data: adno,name,grade,house,area
adno is integer, name is string, grade is string ('12A', '12B' …, '11A', '11B', … '10A', '10B', …),
house is string and area is string
a) Write a Python function to append n (n is local variable in the function) records in the binary
data file 'HOUSE.DAT'. [3]

b) Write a Python function to read the binary data file 'HOUSE.DAT' and display those records
where house is either 'FAITH' or 'TRUST'. If no such record is found then display an appropriate
message. [4]

XII 1st Term Exam 2023-23 Set-A Page 2 / 2 Subject: Computer Science (083)

You might also like