12CS T1 2022 SetB

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Fahaheel Al-Watanieh Indian Private School, Ahmadi, Kuwait

First Term Examination 2022-23 Set


Computer Science (083)
Class XII
B
Time: 2 Hours Maximum Marks: 35
1. Identify the correct options: [1]
a) An else-part with a Python while-loop always gets executed
b) An else-part with a Python finite while-loop gets executed if there is no break
c) An else-part with a Python while-loop is optional
d) An else-part with a Python while-loop is mandatory

2. Identify the correct options: [1]


a) Python list type object is a mutable type
b) Python tuple type object is pass by reference to a function
c) Python tuple type object is an immutable type
d) Python list type object is passed by value to a function

3. Identify the correct options: [1]


a) Python string type object does not support + and * operators
b) Python string type object cannot be empty
c) Python string type object supports + and * operators
d) Python string type object can be empty

4. Identify the correct options: [1]


a) A global variable can only be created with keyword global
b) A global variable can be created without keyword global
c) Keyword global can be used anywhere in a Python script
d) Keyword global can only be used inside a Python function

5. Identify the correct options: [1]


a) File mode is optional for opening a CSV file in read mode
b) File mode needs two letters for opening a binary file
c) File mode needs exactly one letter for opening any file
d) File mode is optional for opening any file in write mode

6. Identify the correct options: [1]


file=open('CLASS.TXT', 'wt')
a) If CLASS.TXT does not exist, it triggers a run-time error
b) If CLASS.TXT does not exist, a new file is created
c) If CLASS.TXT exists, new data will be added at the end of the file
d) If CLASS.TXT exists, new data will overwrite existing data

7. Identify the correct options: [1]


a) seek() returns the position of a file pointer
b) tell() shifts the position of file pointer
c) tell() returns the position of a file pointer
d) seek() shifts the position of file pointer

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

b) def pyfunc(a, b):


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

x, y, c=3, 5, 6
pyfunc(c, x)
pyfunc(c, y)

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

11. Write any two differences between actual parameter and formal parameter. [2]

12. 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 a parameter to 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 area is either 'ABU HALIFA' or 'MAHBOULA'. If no such record is found then display
an appropriate message.
[4]

13. 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 local variable in 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 'CHEM' and nop>24. [4]

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

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

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

You might also like