0% found this document useful (0 votes)
3 views6 pages

Xii A Computer Science Answer Key

The document is an examination paper for Computer Science for Std XII-A at K.V.S. Matriculation Hr. Sec. School, Thoothukudi, covering various topics including subroutines, data consistency, and algorithms. It consists of multiple-choice questions, short answer questions, and detailed questions requiring explanations or code examples. The paper assesses students' understanding of programming concepts, database management, and Python syntax.

Uploaded by

Rajesh Kumar
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)
3 views6 pages

Xii A Computer Science Answer Key

The document is an examination paper for Computer Science for Std XII-A at K.V.S. Matriculation Hr. Sec. School, Thoothukudi, covering various topics including subroutines, data consistency, and algorithms. It consists of multiple-choice questions, short answer questions, and detailed questions requiring explanations or code examples. The paper assesses students' understanding of programming concepts, database management, and Python syntax.

Uploaded by

Rajesh Kumar
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

K.V.S. Matriculation Hr. Sec. School, Thoothukudi.

Half Yearly Examination – December 2021


COMPUTER SCIENCE
Time: 3.00 Hours Marks: 70 Std: XII-A Name:
I. Choose the best answer : [15 × 1 = 15]
1. a) Subroutines
2. b) Lists
3. a) Public members
4. c) comma(,)
5. d) x%4!=0
6. d) third argument of slice operation
7. d) :
8. a) one-to-one
9. a) Line Terminator
10. a) DDL
11. b) Binary mode
12. d) Boost
13. b) Relational Database system
14. d) F5
15. c) Both the statements are correct

II. Answer any six questions. (Question No. 22 is compulsory) [6 × 2 = 12]


16. What is a subroutine?
Subroutines are the basic building blocks of computer programs. Subroutines are small sections of code that
are used to perform a particular task that can be used repeatedly. In Programming languages these subroutines
are called as Functions.

17. Differentiate constructors and selectors.


Constructors are functions that build the abstract data type. Selectors are functions that retrieve information
from the data type.
Constructors create an object, bundling together different pieces of information, while selectors extract
individual pieces of information from the object.

18. What is Mapping?


The process of binding a variable name with an object is called mapping. : = (colon equal to sign) is used in
programming languages to map the variable and object.

19. What is a literal? Explain the types of literals?


Literal is a raw data given to a variable or constant. In Python, there are various types of literals.
1) Numeric
2) String
3) Boolean
(i) Numeric Literals
Numeric Literals consists of digits and are immutable (unchangeable). Numeric literals can belong to 3
different numerical types Integer, Float and Complex.
(ii) String Literals
In Python a string literal is a sequence of characters surrounded by quotes. Python supports single, double
and triple quotes for a string. A character literal is a single character surrounded by single or double quotes. The
value with triple-quote "' '" is used to give multiline string literal.
(iii) Boolean Literals
A Boolean literal can have any of the two values: True or False.

20. What is base condition in recursive function


The condition that is applied in any recursive function is known as base condition. A base
condition is must in every recursive function otherwise it will continue to execute like an
infinite loop.

21. What is data consistency?


Data Consistency On live data, it is being continuously updated and added,
maintaining the consistency of data can become a challenge. But DBMS handles it by
itself.

22. What is use of next() function?


• next()-The next() function returns the next item from the iterator.
• It can also be used to skip a row of the csv file.
• next() command is used to skip the first row or row heading.

23. What is the use of cd command. Give an example.


The syntax to change from c:\> to the folder where Python is located is
cd <absolute path>
Where “cd” command refers to change directory and absolute path refers to the complete path where Python
is installed.
To change a directory 'cd' command is used.

24. Mention the users who uses the Database.


Users of database can be human users, other programs or applications

III. Answer any six questions. (Question No. 32 is compulsory) [6 × 3 = 18]


25. List the characteristics of an algorithm.

 Input  Effectiveness  Feasibility
 Output  Correctness  Portable
 Finiteness  Simplicity  Independent
 Definiteness  Unambiguous

26. Explain Ternary operator with examples.


Ternary operator is also known as conditional operator that evaluate something based on a condition being
true or false. It simply allows testing a condition in a single line replacing the multiline if-else making the
code compact.
The Syntax conditional operator is,
Variable Name = [on_true] if [Test expression] else [on_false]
Example :
min= 50 if 49<50 else 70 # min = 50
min= 50 if 49>50 else 70 # min = 70

27. List the differences between break and continue statements.


break Continue
The break statement terminates the loop Continue statement is used to skip the remaining
containing it. Control of the program flows to the part of a loop and start with next iteration.
statement immediately after the body of the loop.
Program: Program:
for word in "Jump Statement": for word in "Jump Statement":
if word == "e": if word == "e":
break continue
print (word, end= ' ') print (word, end=' ')
Output: Output:
J u m p S t a t J u m p S t a t m n t

28. Write a shot note about sort( ).


sort ( ) Sorts the element in list [Link](reverse=True|False, key=myFunc)
Both arguments are optional
• If reverse is set as True, list sorting is in descending order.
• Ascending is default.
• Key=myFunc; “myFunc” - the name of the user defined function that specifies the sorting criteria.
Note: sort( ) will affect the original list.

MyList=['Thilothamma', 'Tharani', 'Anitha', 'SaiSree', 'Lavanya']


[Link]( )
print(MyList)
[Link](reverse=True)
print(MyList)
Output:
['Anitha', 'Lavanya', 'SaiSree', 'Tharani', 'Thilothamma']
['Thilothamma', 'Tharani', 'SaiSree', 'Lavanya', 'Anitha']

29. What are class members? How do you define it?


Variables defined inside a class are called as “Class Variable” and functions are called as “Methods”. Class
variable and methods are together known as members of the class. The class members should be accessed
through objects or instance of class. A class can be defined anywhere in a Python program.
Example: Program to define a class
class Sample:
x, y = 10, 20 # class variables

30. Write a SQL statement using DISTINCT keyword.


The DISTINCT keyword is used along with the SELECT command to eliminate duplicate rows in the table.
This helps to eliminate redundant data.
For Example:
SELECT DISTINCT Place FROM Student;
Will display the following data as follows :
SELECT * FROM Student;
Place
Chennai
Bangalore
Delhi
In the above output you can see, there would be no duplicate rows in the place field. When the keyword
DISTINCT is used, only one NULL value is returned, even if more NULL values occur.

31. What is the difference between reader( ) and DictReader( ) function?


reader() DictReader()
You can read the contents of CSV file with the To read a CSV file into a dictionary can be done by
help of [Link]() method. using DictReader class,
The reader function is designed to take each line of DictReader works by reading the first line of the
the file and make a list of all columns. CSV and using each comma separated value in this
line as a dictionary key.
csv. reader and [Link] work with list/tuple [Link] and [Link] work with
dictionary.
Syntax: Example:
[Link](fileobject,delimiter,fmtparams) input_file = [Link](open(filename,’r’))

32. Differentiate PYTHON and C++

33. What is SQLite? What is it advantage?


SQLite is a simple relational database system, which saves its data in regular data files or even in the internal
memory of the computer. It is designed to be embedded in applications, instead of using a separate database
server program such as MySQLor Oracle. SQLite is fast, rigorously tested, and flexible, making it easier to
work. Python has a native library for SQLite.
IV. Answer the following questions. [5 × 5 = 25]
34. a. Explain the types of scopes for variable or LEGB rule with example. (23)
(or)
b. What is Binary search? Discuss with example.
Binary Search
Binary search also called half-interval search algorithm. It finds the position of a search element
within a sorted array. The binary search algorithm can be done as divide-and-conquer search
algorithm and
executes in logarithmic time.
Pseudo code for Binary search
1. Start with the middle element:
• If the search element is equal to the middle element of the array i.e., the middle value = number of
elements in array/2, then return the index of the middle element.
• If not, then compare the middle element with the search value,
• If the search element is greater than the number in the middle index, then select the elements to the
right side of the middle index, and go to Step-1.
• If the search element is less than the number in the middle index, then select the elements to the left
side of the middle index, and start with Step-1.
2. When a match is found, display success message with the index of the element matched.
3. If no match is found for all comparisons, then display unsuccessful message.
35. a. Discuss in detail about Tokens in Python. (55)
(or)
b. Write a detail note on for loop (77)
36. a. Write a Python code to find the L.C.M. of two numbers.
Program:
def lcm(x, y):
if x>y:
greater = x
else:
greater = y
while (True):
if ((greater % x == 0) and (greater % y == 0)):
lcm = greater
break
greater = greater + 1
return lcm
a = int (input ("Enter number 1:"))
b = int (input ("Enter number 2:"))
print ("The LCM of ", a, "and", b, "is", lcm(a,b))

Output:
Enter number 1:12
Enter number 2:12
The LCM of 12 and 12 is 12
Enter number 1:12
Enter number 2:24
The LCM of 12 and 24 is 24
b. Explain the different set operations supported by python with suitable example. (158)
37. a. Write the different types of constraints and their functions. (212)
(or)
b. Write the rules to be followed to format the data in a CSV file. (237)
38. a. Write in brief about SQLite and the steps used to use it. (291, 292)
(or)
b. Explain the various buttons in a matplotlib window.
Buttons in the output
In the output figure, you can see few buttons at the bottom left corner. Let us see the use of these buttons.
Home Button
Forward / Back Buttons
Zoom Button
Save the Figure Button
Pan Axis Button
Configure Subplots Button
Home Button → The Home Button will help once you have begun navigating your chart. If you ever want to
return back to the original view, you can click on this.
Forward/Back buttons → These buttons can be used like the Forward and Back buttons in your browser. You
can click these to move back to the previous point you were at, or forward again.
Pan Axis → This cross-looking button allows you to click it, and then click and drag your graph around.
Zoom → The Zoom button lets you click on it, then click and drag a square that you would like to zoom into
specifically. Zooming in will require a left click and drag. You can alternatively zoom out with a right click
and drag.
Configure Subplots → This button allows you to configure various spacing options with your figure and plot.
Save Figure → This button will allow you to save your figure in various forms.

You might also like