0% found this document useful (0 votes)
32 views10 pages

XIIComp SC PT2465

This document outlines the structure and content of a Unit Test for Class XII-A in Computer Science at Visakan Senior Secondary School. It includes various sections with questions of different types, including multiple choice, short answer, and programming tasks, all focused on Python programming. The test is designed to assess students' understanding of Python concepts and their ability to apply them in practical scenarios.
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)
32 views10 pages

XIIComp SC PT2465

This document outlines the structure and content of a Unit Test for Class XII-A in Computer Science at Visakan Senior Secondary School. It includes various sections with questions of different types, including multiple choice, short answer, and programming tasks, all focused on Python programming. The test is designed to assess students' understanding of Python concepts and their ability to apply them in practical scenarios.
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/ 10

VISAKAN SENIOR SECONDARY SCHOOL – CBSE

1
UNIT TEST – VI

SUBJECT: COMPUTER SCIENCE TOTALMARKS: 70


CLASS: XII- A

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

1. Identify the output of the following python statements –

a) GOOD MORNING!Good morning b) Good Morning!Good morning


c)Good morning !Good Morning! d) Good morning Good Morning!

2. What may be the output of the program given below:


a) 0:0 b) 2:4 c) 1:2 d) 0:5
3. Predict the output of the following code:

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?

a) Statement 2 b) Statement 3 c) Statement 4 d) Statement 2 and 4


12.Which function returns the sum of all elements of a list?
a) count() b) sum() c) total() d) add()
13.State whether the following statement is True or False:
An exception may be raised even if the program is syntactically correct.
14.Which of the following functions changes the position of file pointer and
returns its new position?
a) flush() b) tell() c) seek() d) offset()
15.What is the output of “hello”+1+2?
a) hello12 b) hellohellohello c)Error d) hello3
16.Write the statement in Python to declare a dictionary whose keys are 1,2,3
and values are Monday, Tuesday and Wednesday respectively.
17.What is the output of the following Python statements?
x=[[10.0,11.0,12.0],[13.0],14.0,15.0]]
y=x[1][2]
print(y)
a) 12.0 b) 13.0 c) 14.0 d) 15.0
18.Given a tuple tup1=(10,20,30,40,50,60,70,80,90).
What will be the output of print(tup1[3:7:2])?
a) (40,50,60,70,80) b) (40,50,60,70) c) [40,60] d) (40,60)
19.What will be the output of the following code?
Tup1=(1,2,[1,2],3)
Tup1[2][1]=3.14
print(Tup1)
a) 1,2,[3.14,2],3) b) (1,2,[1,3.14],3) c) (1,2,[1,2,3.14) d) Error
Q20 and Q21 are ASSERTION AND REASONING based
questions. Mark the correct choice as
(a) Both A and R are true and R is the correct explanation for
A
(b) Both A and R are true and R is not the correct
explanation for A
(c) A is True but R is False

(d) A is false but R is True

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

22.Write a user defined function in Python named Puzzle(W,N) which takes


the argument W as an English word and N as an integer and returns the
string where every Nth alphabet of the word W is replaced with an
underscore(“_”).
For example: Consider the following dictionary
S={“AMIT”:[92,86,64],”NAGMA”:[65,42,43],”DAVID”:[92,90,88]}
The output should be:
AMIT – B
NAGMA – C
DAVID - A
23.Rewrite the following code in Python after removing all the syntax errors.
Underline each correction done in the code.
num1,num2=10,45
While
num1%num2==0
num+=20
num2+=30
Else:
print('hello')

24.Write a function dispBook(BOOKS) in Python, that takes a dictionary BOOKS


as an argument and displays the names in uppercase of those books whose
name starts with a constant.
For example, Consider the following dictionary
BOOKS={1:”Python”,2:”Internet Fundamentals”,3:”Networking”,4:”Oracle
sets”,5:”Understanding HTML”}
The output should be:
PYTHON
NETWORKING
25.Write a Python Program containing a function FindWord(STRING, SEARCH),
that accepts two arguments: STRING and SEARCH, and prints the count of
occurrence of SEARCH in STRING. Write appropriate statements to call the
function.
For example if STRING=”Learning history helps to know about history with
interest in history” and SEARCH=”history” the function should display The
word history occurs 3 times.
26.Write a suitable Python statement for each of the following tasks using
built-in functions/methods only
(i) To delete an element Mumbai:50 from Dictionary D.
(ii) To display words in a String S in the form of a list.
27. a) Given is a Python list declaration:
Listofnames=[“Aman”,”Ankit”,”Ashish”,”Rajat”]
Write the output of:
print(Listofnames[-1:-4:-1])
b) Consider the following tuple declaration:
tup1=(10,20,30,(10,20,30),40)
Write the output of:
print(tup1.index(20))
28. Write the output of the code given below:

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

32. Sharmistha wants to write python functions:


AddRecord() to add records of students storing student_ID, StudentName
and Score.
ShowReords() to display the records stored in the csv file.
As a Python expert help her in writing the functions.
Where,
Student-ID: stores ID of the student
StudentName: stores name of the student
Score: stores score of the student

33.A list, NList contains following record as list elements:


[City, Country, distance from Delhi]
Each of these records are nested together to form a nested list. Write the
following user defined functions in Python to perform the specified
operations on the stack named travel.
i) Push_element(NList): It takes the nested list as an argument and pushes a
list object containing name of the city and country, which are not in INDIA
and distance is less than 3000km from DELHI.
ii) Pop_element(): It pops the object from the stack and displays them. Also,
the function should display “Stack Empty” when there are no elements in
the stack.
For example: If the nested list contains the following data:
NList=[[“NewYork”,”USA”,11734],[“Naypyidaw”,”Myanmar”,3219],
[“Dubai”,”UAE”,2194],[“London”,”England”,6693],[“Gangtok”,”India”,1580]
,[“Columbo”,”Sri Lanka”,3405]]
The stack should contain:
[‘Naypyidaw’,’Myanmar’],[ [‘Dubai’,’UAE’], ],[‘Columbo’,’Sri Lanka’]
The output should be:
[‘Columbo’,’Sri Lanka’]
[‘Dubai’,’UAE’]
[‘Naypyidaw’,’Myanmar’]
Stack Empty
34. a)Predict the output of the Python code given below:(3)

b) What will be the output of the following.(1)

a)5#8#15#4# b)5#8#5#4# c)5#8#15#14# d) 5#18#15#4#

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?

ALL THE BEST

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy