XIIComp SC PT2465
XIIComp SC PT2465
1
UNIT TEST – VI
General Instructions:
All questions are compulsory
1. Section A has 21 questions carrying 1 mark each
2. Section B has 7 very Short Answer type questions carrying 2 marks each.
3. Section C has 3 Short Answer Type questions carrying 3 marks each.
4. Section D has 4 Case Based Question carrying 4 marks.
5. Section E has 2 Long Answer Type question carrying 5 marks.
6. All programming questions are to be answered using python language only.
7. In case of MCQ, text of the correct answer should also be written.
SECTION – A
a) 50 b) 0 c) Null d) None
4. Select the correct output of the code:
S=”Amrit Mahotsav @ 75”
A=S.partition(“ “)
print(A)
a) (‘Amrit Mahotsav’,’@’,’75’) b) [‘Amrit’,’Mahotsav’,’@’,’75’]
c) (‘Amrit’,’Mahotsav @ 75’) d) (‘Amrit’,’ ‘, ‘Mahotsav @ 75’)
5. Given the following Tuple
Tup=(10,20,30,50)
Which of the following statements will result in an error?
a) print(Tup[0]) b) Tup.insert(2,3) c) print(Tup[1:2]) d) print(len(Tup))
6. Consider the given expression:
5<10 and 12>7 or not 7>4
Which of the following will be the correct output, if the given expression is
evaluated?
a) True b) False c) NONE d) NULL
7. __________ function is used to arrange the elements of a list in ascending
order.
a) sort() b) arrange() c) ascending() d) assort()
8. Which of the following operators will return either True or False?
a)+= b) != c) = d) *=
9. The syntax of seek() is:
File_object.seek(offset[,reference_point])
What is the default value of reference_point?
a)0 b) 1 c) 2 d) 3
10.What will the following expression be evaluated to in Python?
print(4+3*5/3-5%2)
a) 8.5 b) 8.0 c) 10.2 d) 10.0
11.Which of the following statement(s) would give an error after executing the
following code?
20. Assertion(A): The break statement can be used with all selection and iteration
statements.
Reason(B): Using break with an if statement will give no error.
21.Assertion (A): A variable declared inside a function cannot be used outside
it.
Reason (R): A variable created inside a function has a function scope.
SECTION - B
SECTION - C
29.Write a function in Python to read a text file, Alpha.txt and displays those
lines which begin with the word ‘You’.
30.Write a function, vowelCount() in Python that counts and displays the
number of vowels in the text file named Poem.txt.
31.Write a function in Python, Push(Vehicles) where, Vehicle is a dictionary
containing details of vehicles – (Car_name:Maker).
The function should push the name of car manufactured by
“TATA”(including all the possible cases like Tata,TATA, etc) to the stack.
For example:
If the dictionary contains the following data:
Vehicle={“Santro”:”Hyndai”,”Nexon”:”TATA”,”Safari”:”Tata”}
The stack should contain
Safari
Nexon
SECTION - D
35. 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 field elements as fid, fname and fprice to
store furniture id, furniture name and furniture price respectively.
ii) search()- To display the records of the furniture whose price is more than
10000.
SECTION - E
36.a) Give any one point of difference between a binary file and a csv file.
b) 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 ‘record.csv’.
Each record consists of a list with field elements as empid, name and
mobile to store employee id, employee name, and employee salary
respectively.
ii) COUNTR() – To count the number of records present in the CSV file
named ‘record.csv’.
37. Aman is a Python programmer. He has written a code and created a binary
file record.dat with employee id, ename and salary. The file contains 10
records.
He now has to update a record based on the employee id entered by the user
and update the salary. The updated record is then to be written in the file
temp.dat. The records which are not to be updated also have to be written to
the file trmp.dat. If the employee id is not found, an appropriate message
should to be displayed.
As a Python expert, help him to complete the following code based on the
requirement given above.
i) Which module should be imported in the program?(Statement 1)
ii) Write the correct statement required to open a temporary file named
temp.dat.(Statement 2)
iii) Which statement should Aman fill in statement 3 to read the data from
the binary file, record.dat and in Statement 4 to write the updated data in
the file, temp.dat?