Samacheer Kalvi 12th Computer Science Solutions Chapter 10 Python Classes and Objects

Students can Download Computer Science Chapter 10 Python Classes and Objects Questions and Answers, Notes Pdf, Samacheer Kalvi 12th Computer Science Book Solutions Guide Pdf helps you to revise the complete Tamilnadu State Board New Syllabus and score more marks in your examinations.

Tamilnadu Samacheer Kalvi 12th Computer Science Solutions Chapter 10 Python Classes and Objects

Samacheer Kalvi 12th Computer Science Python Classes and Objects Text Book Back Questions and Answers

PART – 1
I. Choose The Best Answer

Question 1.
Which of the following are the key features of an Object Oriented Programming language?
(a) Constructor and Classes
(b) Constructor and Object
(c) Classes and Objects
(d) Constructor and Destructor
Answer:
(c) Classes and Objects

Question 2.
Functions defined inside a class:
(a) Functions
(b) Module
(c) Methods
(d) section
Answer:
(c) Methods

Samacheer Kalvi 12th Computer Science Solutions Chapter 10 Python Classes and Objects

Question 3.
Class members are accessed through which operator?
(a) &
(b) .
(c) #
(d) %
Answer:
(b) .

Question 4.
Which of the following method is automatically executed when an object is created?
(a) _object_( )
(b) _del( )_( )
(c) _func_( )
(d) _init_( )
Answer:
(d) _init_( )

Samacheer Kalvi 12th Computer Science Solutions Chapter 10 Python Classes and Objects

Question 5.
A private class variable is prefixed with
(a) _
(b) &&
(c) ##
(d) **
Answer:
(a) _

Question 6.
Which of the following method is used as destructor?
(a) _init_( )
(b) _dest_ ( )
(c) _rem_( )
(d) _del_( )
Answer:
(d) _del_( )

Samacheer Kalvi 12th Computer Science Solutions Chapter 10 Python Classes and Objects

Question 7.
Which of the following class declaration is correct?
(a) class class_name
(b) class class_name< >
(c) class class_name:
(d) class class_name[ ]
Answer:
(c) class class_name:

Question 8.
Which of the following is the output of the following program?
– class Student:
def_init_(self, name):
self.name=name
S=Student(“Tamil”)
(a) Error
(b) Tamil
(c) name
Answer:
(b) Tamil

Samacheer Kalvi 12th Computer Science Solutions Chapter 10 Python Classes and Objects

Question 9.
Which of the following is the private class variable?
(a) _num
(b) ##num
(c) $$num
(d) &&num
Answer:
(a) _num

Question 10.
The process of creating an object is called as:
(a) Constructor
(b) Destructor
(c) Initialize
(d) Instantiation
Answer:
(d) Instantiation

PART – II
II. Answer The Following Questions

Question 1.
What is class?
Answer:
Classes and Objects are the key features of Object Oriented Programming. Class is the main building block in Python. Object is a collection of data and function that act on those data. Class is a template for the object. According to the concept of Object Oriented Programming, objects are also called as instances of a class or class variable.

Samacheer Kalvi 12th Computer Science Solutions Chapter 10 Python Classes and Objects

Question 2.
What is instantiation?
Answer:
Once a class is created, next you should create an object or instance of that class. The process of creating object is called as “Class Instantiation”.
Syntax:
object_name = class_name( )

Question 3.
What is the output of the following program?
Answer:
class Sample:
_num=10
def disp(self):
print(self._num)
S=Sample( )
S.disp( )
print(S._num)
Output:
Error: Sample has no attribute S._num
10

Samacheer Kalvi 12th Computer Science Solutions Chapter 10 Python Classes and Objects

Question 4.
How will you create constructor in Python?
Answer:
In Python, there is a special function called “init” which act as a Constructor. It must begin and end with double underscore. This function will act as an ordinary function;
General format of init method (Constructor function)
def_init_(self.[args …………….]):
<statements>

Question 5.
What is the purpose of Destructor?
Answer:
Destructor is also a special method gets executed automatically when an object exit from the scope. It is just opposite to constructor. In Python, _del_( ) method is used as destructor.

PART – III
III. Answer The Following Questions

Question 1.
What are class members? How do you define it?
Answer:
In Python, a class is defined by using the keyword class. Every class has a unique name followed by a colon ( : ).
Syntax:
class class_name:
statement_1
statement_2
…………………
…………………
statement_n
Where, statement in a class definition may be a variable declaration, decision control, loop or even a function definition. 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
In the above code, name of the class is Sample and it has two variables x and y having the initial value 10 and 20 respectively. To access the values defined inside the class, you need an object or instance of the class.

Samacheer Kalvi 12th Computer Science Solutions Chapter 10 Python Classes and Objects

Question 2.
Write a class with two private class variables and print the sum using a method?
Answer:
class Sample:
def_init_(self,n1,n2):
self._n1=n1
self._n2=n2
def display(self):
print(“class variable 1:”, self._n1)
print(“class variable 2:”, self._n2)
print(“sum self._n1 + self._n2)
s = sample(10, 20)
s.display( )
Output:
class variable 1 : 10
class variable 2 : 20
sum : 30

Samacheer Kalvi 12th Computer Science Solutions Chapter 10 Python Classes and Objects

Question 3.
Find the error in the following program to get the given output?
class Fruits:
def_init_(self, f1, f2):
self.f1=f1
self.f2=f2
def display (self):
print(“Fruit 1 = %s, Fruit 2 = %s” %(self.fl, self.f2))
F = Fruits (‘Apple’, ‘Mango’)
del F.display
F.display( )
Output
Fruit 1 = Apple, Fruit 2 = Mango
Answer:
In line No. 8, del F.display will not come

Samacheer Kalvi 12th Computer Science Solutions Chapter 10 Python Classes and Objects

Question 4.
What is the output of the following program?
Answer:
class Greeting:
def_init_(self, name):
self._name = name
def display(self):
print(“Good Morning “, self._name)
obj=Greeting(‘Bindu Madhavan’)
obj.display( )
Output:
Bindu Madhavan Good Morning

Samacheer Kalvi 12th Computer Science Solutions Chapter 10 Python Classes and Objects

Question 5.
How do define constructor and destructor in Python?
Answer:
General format of init method (Constructor function)
def_init_(self.[args ……………….]):
<statements>
To define destructor:
_del_ ( ) method is used.

PART – IV
IV. Answer The Following Questions

Question 1.
Write a menu driven program to add or delete stationary items. You should use dictionary to store items and the brand?
Answer:
stationary = { }
while((ch == 1) or (ch == 2))
print(” 1. Add Item \n 2. Delete Item”)
ch = int(input(“Enter your choice “))
if(ch==1):
n = int(input(“Enter the number of items to be added in the stationary shop”))
for i in range(n):
item = input(“Enter an item “)
brand = input(“Enter the brand Name”)
stationary[item] = brand
print(stationary)
elif(ch == 2):
remitem = input(“Enter the item to be deleted from the shop”)
dict.pop(remitem)
print( stationary)
else:
print(“Invalid options. Type 1 to add items and 2 to remove items “)
ch = int(input(“Enter your choice :”)
Output:

  1. Add item
  2. Delete Item Enter your choice : 1

Enter the number of items to be added in the stationary shop : 2
Enter an item : Pen
Enter the brand Name : Trimax
Enter an item : Eraser
Enter the brand Name : Camlin
Pen : Trimax
Eraser : Camlin
Enter your choice : 2
Enter the item to be deleted from the shop : Eraser
Pen : Trimax
Enter your choice : 3
Invalid options. Type 1 to add items an 2 to remove items.

Practice Programs

Question 1.
Write a program using class to store name and marks of students in list and print total marks?
Answer:
class stud:
def_init_(self):
self.name=” ”
self.m1=0
self.m2=0
self.tot=0
def gdata(self):
self.name = input(“Enter your name”)
self.m1 = int(input(“Enter marks 1”))
self.m2 = int(input(“Enter marks2”))
self, tot = self.m1+self.m2
def disp(self):
print(self.name)
print(self.m1)
print(self.m2)
print(self.tot)
mlist = [ ]
st = stud( )
st.gdata( )
mlist. append(st)
for x in mlist:
x.disp( )
Output:
Enter your name Ram
Enter marks 1 100
Enter marks2 100
Ram 100 100 200

Samacheer Kalvi 12th Computer Science Solutions Chapter 10 Python Classes and Objects

Question 2.
Write a program using class to accept three sides of a triangle and print its area?
Answer:
class Tr:
def_init_(self, a, b, c):
self.a = float(a)
self.b = float(b)
self.c = float(c)
def area(self):
s = (self.a + self.b + self.c)/2
return((s*(s-self.a) * (s-self.b) * (s-self.c) ** 0.5)
a = input(“Enter side 1:”)
b = input(“Enter side2:”)
c = input(“Enter side3:”)
ans=Tr(a,b,c)
print(ans.area( ))
Output:
Enter side 1 : 3
Enter side 2 : 4
Enter side 3 : 5
6.0

Samacheer Kalvi 12th Computer Science Solutions Chapter 10 Python Classes and Objects

Question 3.
Write a menu driven program to read, display, add and subtract two distances?
Answer:
class Dist:
def_init_(self):
self, dist 1=0
self.dist 2=0
def read(self):
self.dist 1=int(input(“Enter distance 1”))
self.dist 2=int(input(“Enter distance 2”))
def disp(self):
print(“distance 1”, self.dist 1)
print(“distance 2”, self.dist 2)
def add(self):
print(“Total distances”, self.dist 1+self.dist 2)
def sub(self):
print(“Subtracted distance”, self.dist 1-self.dist 2)
d=Dist( )
choi = “y”
while(choi == “y”):
print(” 1. accept \n 2. Display \n 3. Total \n 4. Subtract”)
ch = int(input(“Enter your choice”))
if(ch==l):
d.read( )
elif(ch==2):
d.disp( )
elif(ch==3):
d.add( )
elif(ch==4):
d.sub( )
else:
print(“Invalid Input…”)
choi = input(“Do you want to continue”)
Output:

  1. Accept
  2. Display
  3. Add
  4. Subtract

Enter your choice : 3
Enter distance 1 : 100
Enter distance 2 : 75
Do you want to continue .. y

  1. Accept
  2. Display
  3. Add
  4. Subtract

Enter your choice : 3
Total distances : 175
Do you want to continue .. y

  1. Accept
  2. Display
  3. Add
  4. Subtract

Enter your choice : 2
Enter distance 1 : 100
Enter distance 2 : 75
Do you want to continue .. y

  1. Accept
  2. Display
  3. Add
  4. Sub

Enter your choice : 4
Subtracted distance : 25
Do you want to continue .. N

Samacheer kalvi 12th Computer Science Python Classes and Objects Additional Questions and Answers

PART – 1
1. Choose The Correct Answer

Question 1.
……………………. are also called as instances of a class or class variable.
Answer:
objects

Samacheer Kalvi 12th Computer Science Solutions Chapter 10 Python Classes and Objects

Question 2.
All integer variables used in python program is an object of class ……………………….
Answer:
int

Question 3.
All the string variables are of object of class ……………………..
Answer:
strings

Question 4.
class is defined by the keyword ………………………
Answer:
class

Samacheer Kalvi 12th Computer Science Solutions Chapter 10 Python Classes and Objects

Question 5.
A statement in a class definition may be a ………………………..
(a) variable declaration
(b) decision control
(c) loop
(d) all of these
Answer:
(d) all of these

Question 6.
………………….. and …………………. are called as members of the class
Answer:
class variables and methods

Question 7.
The first argument of the class method is ……………………….
(a) class
(b) func
(c) def
(d) self
Answer:
(d) self

Samacheer Kalvi 12th Computer Science Solutions Chapter 10 Python Classes and Objects

Question 8.
The statements defined inside the class must be properly indented.
True / false
Answer:
True

Question 9.
The init function should begin and end with
(a) underscore
(b) double underscore
(c) #
(d) S
Answer:
(b) double underscore

Samacheer Kalvi 12th Computer Science Solutions Chapter 10 Python Classes and Objects

Question 10.
…………………….. is used to initialize the class variables.
(a) constructor
(b) destructor
(c) class
(d) objects
Answer:
(a) constructor

Question 11.
Find the correct statement from the following.
(a) constructor function can be defined with arguments
(b) constructor function can be defined without arguments
(c) constructor function can be defined with or without argument
(d) constructor function cannot be defined
Answer:
(c) constructor function can be defined with or without argument

Samacheer Kalvi 12th Computer Science Solutions Chapter 10 Python Classes and Objects

Question 12.
…………………….. is a special function to gets executed automatically when an object exit from the scope.
(a) constructor
(b) init
(c) destructor
(d) object
Answer:
(c) destructor

Question 13.
The variables which are defined inside the class is by default.
(a) private
(b) public
(c) protected
(d) local
Answer:
(b) public

Samacheer Kalvi 12th Computer Science Solutions Chapter 10 Python Classes and Objects

Question 14.
Which variables can be accessed anywhere in the program using dot operator?
(a) private
(b) public
(c) protected
(d) auto
Answer:
(b) public

Question 15.
Which variables can be accessed only within the class?
(a) private
(b) public
(c) protected
(d) local
Answer:
(a) private

Samacheer Kalvi 12th Computer Science Solutions Chapter 10 Python Classes and Objects

Question 16.
Match the following
1. constructor – (i) def process(self)
2. Destructor – (ii) S.x
3. method – (iii) _del_(self)
4. object – (iv) _init_(self, num)
(a) 1-(iv) 2-(iii) 3-(i) 4-(ii)
(b) 1-(i) 2-(ii) 3-(iii) 4-(iv)
(c) 1-(iv) 2-(ii) 3-(i) 4-(iii)
(d) 1-(i) 2-(iii) 3-(iv) 4-(ii)
Answer:
(a) 1-(iv) 2-(iii) 3-(i) 4-(ii)

PART – II
II. Answer The Following Questions

Question 1.
Write note on self?
Answer:
The class method must have the first argument named as self. No need to pass a value for this argument when we call the method. Python provides its value automatically. Even if – a method takes no arguments, it should be defined with the first argument called self. If a method is defined to accept only one argument it will take it as two arguments ie. self and the defined argument.

Samacheer Kalvi 12th Computer Science Solutions Chapter 10 Python Classes and Objects

PART – III
III. Answer The Following Questions

Question 1.
Write the output for the program?
Answer:
class Sample:
def_init_(self, num):
print(“Constructor of class Sample…”)
self.num=num
print(“The value is num)
S=Sample(10)
Constructor of class sample…
The value is: 10

PART – IV
IV. Answer The Following Questions

Question 1.
Write a program to calculate area and circumference of a circle?
Answer:
class Circle:
pi=3.14
def_init_(self,radius):
self.radius=radius
def area(self):
return Circle.pi*(self.radius**2)
def circumference(self):
return 2*Circle.pi*self.radius
r = int(input(“Enter Radius:”))
C=Circle(r)
print(“The Area =”,C.area( ))
print(“The Circumference =”, C.circumference( ))
Output:
Enter Radius: 5
The Area = 78.5
The Circumference = 31.400000000000002

Samacheer Kalvi 12th Computer Science Solutions Chapter 10 Python Classes and Objects

Question 2.
Write a menu driven program that keeps record of books available in your school library?
Answer:
class Library:
def_init_(self):
self.bookname=””
self.author=””
def getdata(self):
self.bookname = input(“Enter Name of the Book: “)
self.author = input(“Enter Author of the Book: “)
def display(self):
print(“Name of the Book: “,self.bookname)
print(” Author of the Book: “,self.author)
print(“\n”)
book=[ ] #empty list
ch = ‘y’
while(ch= =’y’):
print(“1. Add New Book \n 2.Display Books”)
resp = int(input(“Enter your choice :”))
if(resp= =1):
L=Library( )
L.getdata( )
book.append(L)
elif(resp= =2):
for x in book:
x.display( )
else:
print(“Invalid input….”)
ch = input(“Do you want continue….”)
Output:

  1. Add New Book
  2. Display Books

Enter your choice : 1
Enter Name of the Book: Programming in C++
Enter Author of the Book: K. Kannan
Do you want continue….y

  1. Add New Book
  2. Display Books

Enter your choice : 1
Enter Name of the Book: Learn Python
Enter Author of the Book: V.G.Ramakrishnan
Do you want continue….y

  1. Add New Book
  2. Display Books

Enter your choice : 1
Enter Name of the Book: Advanced Python
Enter Author of the Book: Dr. Vidhya
Do you want continue….y

  1. Add New Book
  2. Display Books Enter your choice : 1

Enter Name of the Book: Working with OpenOffice
Enter Author of the Book: N.V.Gowrisankar
Do you want continue….y

  1. Add New Book
  2. Display Books Enter your choice : 1

Enter Name of the Book: Data Structure
Enter Author of the Book: K.Lenin
Do you want continue….y

  1. Add New Book
  2. Display Books

Enter your choice : 1
Enter Name of the Book: An Introduction to Database System
Enter Author of the Book: R.Sreenivasan
Do you want continue….y

  1. Add New Book
  2. Display Books Enter your choice : 2

Enter Name of the Book: Programming in C++
Enter Author of the Book: K. Kannan
Name of the Book: Learn Python
Author of the Book: V.G.Ramakrishnan
Name of the Book: Advanced Python
Author of the Book: Dr. Vidhya
Name of the Book: Working with OpenOffice
Author of the Book: N.V.Gowrisankar
Name of the Book: Data Structure
Author of the Book: K.Lenin
Name of the Book: An Introduction to Database System
Author of the Book: R.Sreenivasan
Do you want continue….n

Samacheer Kalvi 12th Computer Science Solutions Chapter 4 Algorithmic Strategies

Students can Download Computer Science Chapter 4 Algorithmic Strategies Questions and Answers, Notes Pdf, Samacheer Kalvi 12th Computer Science Book Solutions Guide Pdf helps you to revise the complete Tamilnadu State Board New Syllabus and score more marks in your examinations.

Tamilnadu Samacheer Kalvi 12th Computer Science Solutions Chapter 4 Algorithmic Strategies

Samacheer Kalvi 12th Computer Science Algorithmic Strategies Text Book Back Questions and Answers

PART – I
I. Choose The Best Answer

Question 1.
The word comes from the name of a Persian mathematician Abu Jafar Mohammed ibn – i Musa al Khowarizmi is called?
(a) Flow chart
(b) Flow
(c) Algorithm
(d) Syntax
Answer:
(c) Algorithm

Question 2.
From the following sorting algorithms which algorithm needs the minimum number of swaps?
(a) Bubble sort
(b) Quick sort
(c) Merge sort
(d) Selection sort
Answer:
(d) Selection sort

Samacheer Kalvi 12th Computer Science Solutions Chapter 4 Algorithmic Strategies

Question 3.
Two main measures for the efficiency of an algorithm are ……………………………
(a) Processor and memory
(b) Complexity and capacity
(c) Time and space
(d) Data and space
Answer:
(c) Time and space

Question 4.
The complexity of linear search algorithm is ……………………………
(a) O(n)
(b) O(log n)
(c) O(n2)
(d) O(n log n)
Answer:
(a) O(n)

Samacheer Kalvi 12th Computer Science Solutions Chapter 4 Algorithmic Strategies

Question 5.
From the following sorting algorithms which has the lowest worst case complexity?
(a) Bubble sort
(b) Quick sort
(c) Merge sort
(d) Selection sort
Answer:
(c) Merge sort

Question 6.
Which of the following is not a stable sorting algorithm?
(a) Insertion sort
(b) Selection sort
(c) Bubble sort
(d) Merge sort
Answer:
(b) Selection sort

Samacheer Kalvi 12th Computer Science Solutions Chapter 4 Algorithmic Strategies

Question 7.
Time complexity of bubble sort in best case is ……………………………
(a) θ(n)
(b) θ(n log n)
(c) θ(n2)
(d) θ(n(logn) 2)
Answer:
(a) θ(n)

Question 8.
The \(\Theta\) notation in asymptotic evaluation represents
(a) Base case
(b) Average case
(c) Worst case
(d) NULL case
Answer:
(b) Average case

Samacheer Kalvi 12th Computer Science Solutions Chapter 4 Algorithmic Strategies

Question 9.
If a problem can be broken into subproblems which are reused several times, the problem possesses which property?
Answer:
(a) Overlapping subproblems
(b) Optimal substructure
(c) Memoization
(d) Greedy
Answer:
(a) Overlapping subproblems

Question 10.
In dynamic programming, the technique of storing the previously calculated values is called?
(a) Saving value property
(b) Storing value property
(c) Memoization
(d) Mapping
Answer:
(c) Memoization

PART – II
II. Answer The Following Questions

Question 1.
What is an Algorithm?
Answer:
An algorithm is a finite set of instructions to accomplish a particular task. It is a step-by-step procedure for solving a given problem. An algorithm can be implemented in any suitable programming language.

Samacheer Kalvi 12th Computer Science Solutions Chapter 4 Algorithmic Strategies

Question 2.
Define Pseudo code?
Answer:

  1. Pseudo code is a mix of programming – language – like constructs and Plain English.
  2. Pseudo code is a notation similar to programming languages. Algorithms expressed in pseudo code are not intended to be executed by computers, but for communication among people.

Question 3.
Who is an Algorist?
Answer:

  1. A person skilled in the design of algorithms are called as Algorist.
  2. An algorithmic artist.

Question 4.
What is Sorting?
Answer:
Sorting is a method of arranging group of items in an ascending or descending order. Various sorting techniques in algorithms are Bubble Sort, Quick Sort, Heap Sort, Selection Sort, Insertion Sort.

Samacheer Kalvi 12th Computer Science Solutions Chapter 4 Algorithmic Strategies

Question 5.
What is searching? Write its types?
Answer:
A search algorithm is the step-by-step procedure used to locate specific data among a collection of data. Types of searching algorithms are

  1. Linear search
  2. Binary search
  3. Hash search
  4. Binary Tree search

PART – III
III. Answer The Following Questions

Question 1.
List the characteristics of an algorithm?
Answer:
Input, Output, Finiteness, Definiteness, Effectiveness, Correctness, Simplicity, Unambiguous, Feasibility, Portable and Independent.

Samacheer Kalvi 12th Computer Science Solutions Chapter 4 Algorithmic Strategies

Question 2.
Discuss about Algorithmic complexity and its types?
Answer:
The complexity of an algorithm f(n) gives the running time and/or the storage space required by the algorithm in terms of n as the size of input data.

Time Complexity:
The Time complexity of an algorithm is given by the number of steps taken by the algorithm to complete the process.

Space Complexity:
Space complexity of an algorithm is the amount of memory required to run to its completion.

Samacheer Kalvi 12th Computer Science Solutions Chapter 4 Algorithmic Strategies

Question 3.
What are the factors that influence time and space complexity?
Answer:
Time Complexity:
The Time complexity of an algorithm is given by the number of steps taken by the algorithm to complete the process.

Space Complexity:
Space complexity of an algorithm is the amount of memory required to run to its completion. The space required by an algorithm is equal to the sum of the following two components:

A fixed part is defined as the total space required to store certain data and variables for an algorithm. For example, simple variables and constants used in an algorithm. A variable part is defined as the total space required by variables, which sizes depends on the problem and its iteration. For example: recursion used to calculate factorial of a given value n.

Samacheer Kalvi 12th Computer Science Solutions Chapter 4 Algorithmic Strategies

Question 4.
Write a note on Asymptotic notation?
Answer:
Asymptotic Notations:
Asymptotic Notations are languages that uses meaningful statements about time and space complexity.

(I) Big O
Big O is often used to describe the worst – case of an algorithm.

(II) Big Ω
Big Omega is the reverse Big O, if Bi O is used to describe the upper bound (worst – case) of a asymptotic function, Big Omega is used to describe the lower bound (best-case).

(III) Big \(\Theta\)
When an algorithm has a complexity with lower bound = upper bound, say that an algorithm has a complexity O (n log n) and Ω (n log n), it’s actually has the complexity \(\Theta\) (n log n), which means the running time of that algorithm always falls in n log n in the best – case and worst – case.

Samacheer Kalvi 12th Computer Science Solutions Chapter 4 Algorithmic Strategies

Question 5.
What do you understand by Dynamic programming?
Answer:
Dynamic programming is an algorithmic design method that can be used when the solution to a problem can be viewed as the result of a sequence of decisions. Dynamic programming approach is similar to divide and conquer. The given problem is divided into smaller and yet smaller possible sub – problems.

PART – IV
IV. Answer The Following Questions

Question 1.
Explain the characteristics of an algorithm?
Answer:

  1. Input – Zero or more quantities to be supplied.
  2. Output – At least one quantity is produced.
  3. Finiteness – Algorithms must terminate after finite number of steps.
  4. Definiteness – All operations should be well defined. For example operations involving division by zero or taking square root for negative number are unacceptable.
  5. Effectiveness – Every instruction must be carried out effectively.
  6. Correctness – The algorithms should be error free.
  7. Simplicity – Easy to implement.
  8. Unambiguous – Algorithm should be clear and unambiguous. Each of its steps and their inputs/outputs should be clear and must lead to only one meaning.
  9. Feasibility – Should be feasible with the available resources.
  10. Portable – An algorithm should be generic, independent of any programming language or an operating system able to handle all range of inputs.
  11. Independent – An algorithm should have step-by-step directions, which should be independent of any programming code.

Samacheer Kalvi 12th Computer Science Solutions Chapter 4 Algorithmic Strategies

Question 2.
Discuss about Linear search algorithm.?
Answer:
Linear Search:
Linear search also called sequential search is a sequential method for finding a particular value in a list. This method checks the search element with each element in sequence until the desired element is found or the list is exhausted. In this searching algorithm, list need not be ordered.

Pseudo code:
(I) Traverse the array using for loop
(II) In every iteration, compare the target search key value with the current value of the list.

  1. If the values match, display the current index and value of the array
  2. If the values do not match, move on to the next array element.

(III) If no match is found, display the search element not found.
To search the number 25 in the array given below, linear search will go step by step in a sequential order starting from the first element in the given array if the search element is found that index is returned otherwise the search is continued till the last index of the array. In this example number 25 is found at index number 3.
Samacheer kalvi 12th Computer Science Solutions Chapter 4 Algorithmic Strategies
Example 1:
Input: values[ ] = {5, 34, 65, 12, 77, 35}
target = 77
Output: 4
Example 2:
Input: values[ ] = {101, 392, 1, 54, 32, 22, 90, 93}
target = 200
Output: -1 (not found)

Samacheer Kalvi 12th Computer Science Solutions Chapter 4 Algorithmic Strategies

Question 3.
What is Binary search? Discuss with example?
Answer:
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:
(I) 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 f the middle index, and start with Step-1.

(II) When a match is found, display success message with the index of the element matched.
(III) If no match is found for all comparisons, then display unsuccessful message.

Binary Search Working principles:
List of elements in an array must be sorted first for Binary search. The following example describes the step by step operation of binary search. Consider the following array of elements, the array is being sorted so it enables to do the binary search algorithm. Let us assume that the search element is 60 and we need to search the location or index of search element 60 using binary search.
Samacheer Kalvi 12th Computer Science Solutions Chapter 4 Algorithmic Strategies
First, we find index of middle element of the array by using this formula:
mid = low + (high – low) / 2
Here it is, 0 + (9 – 0 ) / 2 = 4 (fractional part ignored). So, 4 is the mid value of the array.
Samacheer Kalvi 12th Computer Science Solutions Chapter 4 Algorithmic Strategies
Now compare the search element with the value stored at mid value location 4. The value stored at location or index 4 is 50, which is not match with search element. As the search value 60 is greater than 50.
Samacheer Kalvi 12th Computer Science Solutions Chapter 4 Algorithmic Strategies
Now we change our low to mid + 1 and find the new mid value again using the formula, low to mid – 1
mid = low + (high – low) / 2
Our new mid is 7 now. We compare the value stored at location 7 with our target value 31.
Samacheer Kalvi 12th Computer Science Solutions Chapter 4 Algorithmic Strategies
The value stored at location or index 7 is not a match with search element, rather it is more than what we are looking for. So, the search element must be in the lower part from the current mid value location
Samacheer kalvi 12th Computer Science Solutions Chapter 4 Algorithmic Strategies
The search element still not found. Hence, we calculated the mid again by using the formula.
high = mid – 1
mid = low + (high – low) / 2
Now the mid value is 5.
Samacheer Kalvi 12th Computer Science Solutions Chapter 4 Algorithmic Strategies
Now we compare the value stored at location 5 with our search element. We found that it is a match.
Samacheer Kalvi 12th Computer Science Solutions Chapter 4 Algorithmic Strategies
We can conclude that the search element 60 is found at location or index 5. For example if we take the search element as 95, For this value this binary search algorithm return unsuccessful result.

Samacheer Kalvi 12th Computer Science Solutions Chapter 4 Algorithmic Strategies

Question 4.
Explain the Bubble sort algorithm with example?
Answer:
Bubble sort algorithm:
Bubble sort is a simple sorting algorithm. The algorithm starts at the beginning of the list of values stored in an array. It compares each pair of adjacent elements and swaps them if they are in the unsorted order. This comparison and passed to be continued until no swaps are needed, which indicates that the list of values stored in an array is sorted. The algorithm is a comparison sort, is named for the way smaller elements “bubble” to the top of the list.

Although the algorithm is simple, it is too slow and less efficient when compared to insertion sort and other sorting methods. Assume list is an array of n elements. The swap function swaps the values of the given array elements.

Pseudo code:

  1. Start with the fist element i.e., index = 0, compare the current element with the next element of the array.
  2. If the current element is greater than the next element of the array, swap them.
  3. If the current element is less than the next or right side of the element, move to the next element. Go to Step 1 and repeat until end of the index is reached.

Let’s consider an array with values {15, 11, 16, 12, 14, 13} Below, we have a pictorial representation of how bubble sort will sort the given array.
Samacheer Kalvi 12th Computer Science Solutions Chapter 4 Algorithmic Strategies
The above pictorial example is for iteration – 1. Similarly, remaining iteration can be done. The final iteration will give the sorted array.
At the end of all the iterations we will get the sorted values in an array as given below:
Samacheer Kalvi 12th Computer Science Solutions Chapter 4 Algorithmic Strategies

Samacheer Kalvi 12th Computer Science Solutions Chapter 4 Algorithmic Strategies

Question 5.
Explain the concept of Dynamic programming with suitable example?
Answer:
Dynamic programming:
Dynamic programming is an algorithmic design method that can be used when the solution to a problem can be viewed as the result of a sequence of decisions. Dynamic programming approach is similar to divide and conquer. The given problem is divided into smaller and yet smaller possible sub – problems.

Dynamic programming is used whenever problems can be divided into similar sub-problems, so that their results can be re-used to complete the process. Dynamic programming approaches are used to find the solution in optimized way. For every inner sub problem, dynamic algorithm will try to check the results of the previously solved sub-problems. The solutions of overlapped sub – problems are combined in order to get the better solution.

Steps to do Dynamic programming:

  1. The given problem will be divided into smaller overlapping sub-problems.
  2. An optimum solution for the given problem can be achieved by using result of smaller sub – problem.
  3. Dynamic algorithms uses Memoization.

Fibonacci Series – An example:
Fibonacci series generates the subsequent number by adding two previous numbers. Fibonacci series starts from two numbers – Fib 0 & Fib 1. The initial values of fib 0 & fib 1 can be taken as 0 and 1.
Fibonacci series satisfies he following conditions:
Fibn = Fibn-1 + Fibn-2
Hence, a Fibonacci series for the n value 8 can look like this
Fib8 = 0 1 1 2 3 5 8 13

Fibonacci Iterative Algorithm with Dynamic programming approach:
The following example shows a simple Dynamic programming approach for the generation of Fibonacci series.
Initialize f0 = 0, f1 = 1
step – 1: Print the initial values of Fibonacci f0 and f1
step – 2: Calculate fibanocci fib ← f0 + f1
step – 3: Assign f0 ← f1, f1 ← fib
step – 4: Print the next consecutive value of Fibonacci fib
step – 5: Go to step – 2 and repeat until the specified number of terms generated
For example if we generate fibonacci series up to 10 digits, the algorithm will generate the series as shown below:
The Fibonacci series is: 0 1 1 2 3 5 8 1 3 2 1 3 4 5 5

Samacheer kalvi 12th Computer Science Algorithmic Strategies Additional Questions and Answers

PART – I
I. Choose The Best Answer

Question 1.
Which one of the following is not a data structure?
(a) Array
(b) Structures
(c) List, tuples
(d) Database
Answer:
(d) Database

Samacheer Kalvi 12th Computer Science Solutions Chapter 4 Algorithmic Strategies

Question 2.
The word Algorithm has come to refer to a method ……………………………
(a) Solve a problem
(b) Insert a data
(c) Delete data
(d) Update data
Answer:
(a) Solve a problem

Question 3.
Which is wrong fact about the algorithm?
(a) It should be feasible
(b) Easy to implement
(c) It should be independent of any programming languages
(d) It should be generic
Answer:
(c) It should be independent of any programming languages

Question 4.
Complete the diagram
Samacheer kalvi 12th Computer Science Solutions Chapter 4 Algorithmic Strategies
Answer:
Process

Question 5.
An algorithm that yields expected output for a valid input is called as ……………………………
Answer:
Algorithmic solution.

Samacheer Kalvi 12th Computer Science Solutions Chapter 4 Algorithmic Strategies

Question 6.
Program should be written for the selected language with specific ……………………………
Answer:
Syntax

Question 7.
…………………………… is an expression of algorithm in a programming language.
Answer:
Program

Question 8.
How many different phases are there in the analysis of algorithms and performance evaluations?
(a) 1
(b) 2
(c) 3
(d) Many
Answer:
(b) 2

Samacheer Kalvi 12th Computer Science Solutions Chapter 4 Algorithmic Strategies

Question 9.
Which one of the following is a theoretical performance analysis of an algorithm?
(a) A posteriori testing
(b) A priori estimates
(c) A preposition
(d) A post preori
Answer:
(b) A priori estimates

Question 10.
…………………………… is called performance measurement.
(a) A posteriori testing
(b) A priori estimates
(c) A preposition
(d) A post preori
Answer:
(a) A posteriori testing

Samacheer Kalvi 12th Computer Science Solutions Chapter 4 Algorithmic Strategies

Question 11.
Time is measured by counting the number of key operations like comparisons in the sorting algorithm. This is called as ……………………………
(a) Space Factor
(b) Key Factor
(c) Priori Factor
(d) Time Factor
Answer:
(d) Time Factor

Question 12.
Which of the following statement is true?
(a) Space Factor is the maximum memory space required by an algorithm
(b) Space Factor is the minimum memory spaces required by an algorithm
Answer:
(a) Space Factor is the maximum memory space required by an algorithm

Samacheer Kalvi 12th Computer Science Solutions Chapter 4 Algorithmic Strategies

Question 13.
In space complexity, the space required by an algorithm is equal to the sum of …………………………… part and …………………………… part.
Answer:
Fixed, Variable

Question 14.
…………………………… is an example for variable part of space complexity.
Answer:
Recursion

Question 15.
A …………………………… or …………………………… trade off is a way of solving in less time by using more storage space or by solving a given algorithm in very little space by spending more time.
Answer:
Space – timw, time – memory

Samacheer Kalvi 12th Computer Science Solutions Chapter 4 Algorithmic Strategies

Question 16.
Which is true related to the efficiency of an algorithm?
(I) Less time, more storage space
(II) More time, very little space
(a) I is correct
(b) II is correct
(c) Both are correct
(d) Both are wrong
Answer:
(c) Both are correct

Question 17.
How many asymptotic notations are used to represent time complexity of an algorithms?
(a) 1
(b) 2
(c) 3
(d) 4
Answer:
(c) 3

Samacheer Kalvi 12th Computer Science Solutions Chapter 4 Algorithmic Strategies

Question 18.
Which one of the following is not an Asymptotic notations?
(a) Big
(b) Big \(\Theta\)
(c) Big Ω
(d) Big ⊗
Answer:
(d) Big ⊗

Question 19.
………………………… is the reverse of Big O
(a) Big Ω
(b) Big \(\Theta\)
(c) Big C
(d) Big ⊗
Answer:
(a) Big Ω

Question 20.
………………………… describes the worst case of an algorithm.
(a) Big Q
(b) Big \(\Theta\)
(c) Big O
(d) Big C
Answer:
(c) Big O

Samacheer Kalvi 12th Computer Science Solutions Chapter 4 Algorithmic Strategies

Question 21.
…………………….. describes the lower bound of an algorithm.
(a) Big Ω
(b) Big \(\Theta\)
(c) Big O
(d) Big ⊗
Answer:
(a) Big Ω

Question 22.
Which search technique is also called sequential search techniques?
(a) Binary
(b) Binary Tree
(c) Hash
(d) Linear
Answer:
(d) Linear

Question 23.
What value will be returned by the linear search technique if value is not found?
(a) 0
(b) 1
(c) -1
(d) +1
Answer:
(c) -1

Samacheer Kalvi 12th Computer Science Solutions Chapter 4 Algorithmic Strategies

Question 24.
Which search algorithm is called as Half – Interval search algorithm?
(a) Binary
(b) Binary Tree
(c) Hash
(d) Linear
Answer:
(a) Binary

Question 25.
Which technique is followed by Binary Search algorithm?
(a) Subroutines
(b) Mapping
(c) Divide and conquer
(d) Namespaces
Answer:
(c) Divide and conquer

Samacheer Kalvi 12th Computer Science Solutions Chapter 4 Algorithmic Strategies

Question 26.
In Binary Search, if the search element is …………………….. to the middle element of the array, then index of the middle element is returned.
(a) >
(b) <
(c) =
(d) < >
Answer:
(c) =

Question 27.
In Binary search, if the search element is greater than the number in the middle index, then select the elements to the side of the middle index.
(a) Right
(b) Left
(c) Middle
(d) Bottom
Answer:
(a) Right

Question 28.
Fill in the box [Formula for Binary Search]
mid = low + (high – low) / Samacheer kalvi 12th Computer Science Solutions Chapter 4 Algorithmic Strategies
Answer:
2

Question 29.
……………………… is a simple sorting algorithm.
(a) Binary
(b) Bubble
(c) Selection
(d) Insertion
Answer:
(b) Bubble

Samacheer Kalvi 12th Computer Science Solutions Chapter 4 Algorithmic Strategies

Question 30.
Which one of the following is not a characteristics of Bubble Sort?
(a) Simple
(b) Too slow
(c) Too fast
(d) Less efficient
Answer:
(c) Too fast

Question 31.
In selection sort, there will be ……………………….. exchange for every pass through the list.
(a) 0
(b) 1
(c) 2
(d) 3
Answer:
(b) 1

Samacheer Kalvi 12th Computer Science Solutions Chapter 4 Algorithmic Strategies

Question 32.
How many number of passes are used in the Insertion Sort to get the final sorted list?
(a) 0
(b) 1
(c) n
(d) n -1
Answer:
(d) n – 1

Question 33.
………………………….. approach is similar to divide and conquer.
Answer:
Dynamic programming

Question 34.
………………………… is an example for dynamic programming approach.
(a) Fibonacci
(b) Prime
(c) Factorial
(d) Odd or Even
Answer:
(a) Fibonacci

Samacheer Kalvi 12th Computer Science Solutions Chapter 4 Algorithmic Strategies

Question 35.
Match the following.
(1) Linear search – (i) o(n2)
(2) Binary – (ii) o(n)
(3) Bubble Sort – (iii) o(log n)
(4) Merge Sort – (iv) o(n log n)
(a) 1 – (ii), 2 – (iii), 3 – (i), 4 – (iv)
(b) 1 – (i), 2 – (ii), 3 – (iii), 4 – (iv)
(c) 1 – (iv), 2 – (iii), 3 – (ii), 4 – (i)
(d) 1 – (iv), 2 – (ii), 3 – (i), 4 – (iii)
Answer:
(a) 1 – (ii), 2 – (iii), 3 – (i), 4 – (iv)

Samacheer Kalvi 12th Computer Science Solutions Chapter 4 Algorithmic Strategies

Question 36.
Time complexity of bubble sort in worst case is …………………………..
(a) θ(n)
(b) θ(n log n)
(c) θ(n2)
(d) θ(n(log n)2)
Answer:
(c) θ(n2)

Question 37.
The complexity of Merge Sort is …………………………
Answer:
o (n log n)

Question 38.
The complexity of Bubble Sort is …………………………
Answer:
o (n2)

Question 39.
The complexity of Binary search is ……………………….
Answer:
o (log n)

Samacheer Kalvi 12th Computer Science Solutions Chapter 4 Algorithmic Strategies

Question 40.
Pick the odd one out.
Merge Sort, Bubble, Binary, Insertion.
Answer:
Binary

PART – II
II. Answer The Following Questions

Question 1.
Define fixed part in the space complexity?
Answer:
A fixed part is defined as the total space required to store certain data and variables for an algorithm. For example, simple variables and constants used in an algorithm.

Samacheer Kalvi 12th Computer Science Solutions Chapter 4 Algorithmic Strategies

Question 2.
What is space – Time Trade off?
Answer:
A space – time or time – memory trade off is a way of solving in less time by using more storage space or by solving a given algorithm in very little space by spending more time.

PART – III
III. Answer The Following Questions

Question 1.
Design an algorithm to find square of the given number and display the result?
Answer:
Problem: Design an algorithm to find square of the given number and display the result. The algorithm can be written as:
Step 1 – start the process
Step 2 – get the input x
Step 3 – calculate the square by multiplying the input value ie., square ← x* x
Step 4 – display the result square
Step 5 – stop
Algorithm could be designed to get a solution of a given problem. A problem can be solved in many ways. Among many algorithms the optimistic one can be taken for implementation.

Samacheer Kalvi 12th Computer Science Solutions Chapter 4 Algorithmic Strategies

Question 2.
Differentiate Algorithm and Program?
Answer:
Algorithm:

  1. Algorithm helps to solve a given problem logically and it can be contrasted with the program.
  2. Algorithm can be categorized based on their implementation methods, design techniques etc.
  3. There is no specific rules for algorithm writing but some guidelines should be followed.
  4. Algorithm resembles a pseudo code which can be implemented in any language

Program:

  1. Program is an expression of algorithm in a programming language.
  2. Algorithm can be implemented by structured or object oriented programming approach.
  3. Program should be written for the selected language with specific syntax
  4. Program is more specific o a programming language

Samacheer Kalvi 12th Computer Science Solutions Chapter 4 Algorithmic Strategies

Question 3.
What are the two phases in the Analysis of algorithms and performance evaluation?
Answer:
Analysis of algorithms and performance evaluation can be divided into two different phases:
(a) A Priori estimates: This is a theoretical performance analysis of an algorithm. Efficiency of an algorithm is measured by assuming the external factors.
(b) A Posteriori testing: This is called performance measurement. In this analysis, actual statistics like running time and required for the algorithm executions are collected.

Question 4.
Name the factors where the program execution time depends on?
The program execution time depends on:

  1. Speed of the machine
  2. Compiler and other system Software tools
  3. Operating System
  4. Programming language used
  5. Volume of data required

Samacheer Kalvi 12th Computer Science Solutions Chapter 4 Algorithmic Strategies

Question 5.
Write note on Big \(\Theta\)?
Answer:
Big \(\Theta\)
When an algorithm has a complexity with lower bound = upper bound, say that an algorithm has a complexity O (n log n) and Ω . (n log n), it’s actually has the complexity \(\Theta\) (n log n), which means the running time of that algorithm always falls in n log n in the best – case and worst – case.

PART – IV
IV. Answer The Following Questions

Question 1.
Explain Selection Sort?
Answer:
Selection sort
The selection sort is a simple sorting algorithm that improves on the performance of bubble sort by making only one exchange for every pass through the list. This algorithm will first find the smallest elements in array and swap it with the element in the first position of an array, then it will find the second smallest element and swap that element with the element in the second position, and it will continue until the entire array is sorted in respective order. This algorithm repeatedly selects the next-smallest element and swaps in into the right place for every pass. Hence it is called selection sort.

Pseudo code:
(I) Start from the first element (i.e.), index – 0, we search the smallest element in the array, and replace it with the element in the first position.

(II) Now we move on to the second element position, and look for smallest element present in the sub-array, from starting index to till the last index of sub – array.

(III) Now replace the second smallest identified in step-2 at the second position in the or original array, or also called first position in the sub array.

(IV) This is repeated, until the array is completely sorted.
Let’s consider an array with values {13, 16, 11, 18, 14, 15}
Below, we have a pictorial representation of how selection sort will sort the given array
Samacheer kalvi 12th Computer Science Solutions Chapter 4 Algorithmic Strategies
In the first pass, the smallest element will be 11, so it will be placed at the first position. After that, next smallest element will be searched from an array. Now we will get 13 as the smallest, so it will be then placed at the second position.

Then leaving the first element, next smallest element will be searched, from the remaining elements. We will get 13 as the smallest, so it will be then placed at the second position. Then leaving 11 and 13 because they are at the correct position, we will search for the next smallest element from the rest of the elements and put it at third position and keep doing this until array is sorted.
Finally we will get the sorted array end of the pass as shown above diagram.

Samacheer Kalvi 12th Computer Science Solutions Chapter 4 Algorithmic Strategies

Question 2.
Explain Insertion Sort?
Answer:
Insertion Sort
Insertion sort is a simple sorting algorithm. It works by taking elements from the list one by one and inserting then in their correct position in to a new sorted list. This algorithm builds the final sorted array at the end. This algorithm uses n-1 number of passes to get the final sorted list as per the previous algorithm as we have discussed.
Pseudo for Insertion sort
Step 1 – If it is the first element, it is already sorted.
Step 2 – Pick next element
Step 3 – Compare with all elements in the sorted sub-list
Step 4 – Shift all the elements in the sorted sub-list that is greater than the value to be sorted
Step 5 – Insert the value
Step 6 – Repeat until list is sorted
Samacheer Kalvi 12th Computer Science Solutions Chapter 4 Algorithmic Strategies
At the end of the pass the insertion sort algorithm gives the sorted output in ascending order as shown below:
Samacheer Kalvi 12th Computer Science Solutions Chapter 4 Algorithmic Strategies

Samacheer Kalvi 11th Computer Applications Solutions Chapter 13 CSS – Cascading Style Sheets

Students can Download Computer Applications Chapter 13 CSS – Cascading Style Sheets Questions and Answers, Notes Pdf, Samacheer Kalvi 11th Computer Applications Book Solutions Guide Pdf helps you to revise the complete Tamilnadu State Board New Syllabus and score more marks in your examinations.

Tamilnadu Samacheer Kalvi 11th Computer Applications Solutions Chapter 13 CSS – Cascading Style Sheets

Samacheer Kalvi 11th Computer Applications CSS – Cascading Style Sheets Text Book Back Questions and Answers

I. Choose The Correct Answer

Question 1.
Expansion of CSS:
(a) Cascading Style Schools
(b) Cascading Style Scheme
(c) Cascading Style Sheets
(d) Cascading Style Shares
Answer:
(c) Cascading Style Sheets

Samacheer Kalvi 11th Computer Applications Solutions Chapter 13 CSS - Cascading Style Sheets

Question 2.
Which of the following is the page level style?
(a) <Page>
(b) <Style>
(c) <Link>
(d) <H>
Answer:
(b) <Style>

Question 3.
CSS is also called as:
(a) Sitewide Style Sheets
(b) Internal Style Sheets
(c) Inline Style Sheets
(d) Internal Inline Sheets
Answer:
(a) Sitewide Style Sheets

Samacheer Kalvi 11th Computer Applications Solutions Chapter 13 CSS - Cascading Style Sheets

Question 4.
The extension of CSS file is:
(a) .ssc
(b) .css
(c) .CSC
(d) .htm
Answer:
(b) .css

Question 5.
What is selector?
(a) Property
(b) Value
(c) HTML tag
(d) Name
Answer:
(c) HTML tag

Samacheer Kalvi 11th Computer Applications Solutions Chapter 13 CSS - Cascading Style Sheets

Question 6.
The Declaration block of CSS is surrounded by:
(a) ( )
(b) [ ]
(c) { }
(d) <>
Answer:
(c) { }

Question 7.
The declaration should be terminated by:
(a) :
(b) ;
(c) .
(d) ,
Answer:
(b) ;

Question 8.
What is the property to set text as bold?
(a) Font-Style
(b) Font-Weight
(c) Font-Property
(d) Font-Bold
Answer:
(b) Font-Weight

Samacheer Kalvi 11th Computer Applications Solutions Chapter 13 CSS - Cascading Style Sheets

Question 9.
Which of the following indicates that the text included is a comment?
(a) /**/
(b) !* *!
(c) <* *>
(d) \* *\
Answer:
(a) /**/

Samacheer Kalvi 11th Computer Applications Solutions Chapter 13 CSS - Cascading Style Sheets

Question 10.
Which of the following ways below is correct, to write a CSS?
(a) p{coloured; text-align:center};
(b) p {colonred; text-align:center}
(c) p {color:red; text-align:center;}
(d) p (color:red;text-align:center;)
Answer:
(c) p {color:red; text-align:center;}

II. Answer To The Following Questions

Question 1.
What is the use of <style> tag?
Answer:
We are already know about the formatting tags and its attributes, in some situations, you may need to use a tag uniformly in the entire document. To do so, we can use <style> tag. A style tag is used to change the default characteristics of a particular tag in the entire web document wherever that tag is used.

Samacheer Kalvi 11th Computer Applications Solutions Chapter 13 CSS - Cascading Style Sheets

Question 2.
What is CSS?
Answer:
Cascading Style Sheets (CSS) are also called as Sitewide Style sheets or external style. CSS is a style sheet language used for describing the formatting of a document written in HTML. Using CSS, you can control the font colour, font style, spacing between pages, columns size, border colour, background image or colour and various other effects in a web page.

Question 3.
Write the general format of linking CSS with HTML?
Answer:
The <link> tag is used to add CSS file with HTML in head section. While using <link> tag, the following attributes are also included along with standard values.
rel = “stylesheet”
type = “text/css”
The href attribute is used to link the .css file. General format of <Link> tag:
<Link rel = “stylesheet” type = “text/css” href = CSS_ File_Name_with_Extension>

Samacheer Kalvi 11th Computer Applications Solutions Chapter 13 CSS - Cascading Style Sheets

Question 4.
What is Inline Style?
Answer:
“Inline style”, which is used to define style for a particular tag anywhere in an HTML document. You can define styles for any tag within an HTML document. But it is applicable only on that line where it is defined. If you use the same tag, again in the same documnet, it does not reflect the new style.

Samacheer Kalvi 11th Computer Applications Solutions Chapter 13 CSS - Cascading Style Sheets

Question 5.
Write down general format of CSS declaration?
Answer:
The body of the style sheet consists of a series of rules.

Selector:
HTML Tag

Declaration:
{Properties: Values}

III. Answer To The Following Questions

Question 1.
What are the advantages of using CSS?
Answer:
Maintainability:
CSS are also defined and stored as separate files. So, the style and appearance of a web page can be dynamically changed and maintain with less effort.

Reusability:
The styles defined in CSS can be reused in multiple HTML pages.

Easy to understand:
The tags in web pages are well organized with style specifications and therefore it is easy to understand.

Samacheer Kalvi 11th Computer Applications Solutions Chapter 13 CSS - Cascading Style Sheets

Question 2.
Write a short note on rule of CSS?
Answer:
CSS style declaration consists of two major parts; Selector and Declaration. The Selector refers an HTML tag in which you want to apply styles.

The Declaration is a block of code contains style definition. It should be surrounded by curly braces. You can include any number of properties for each selector, and they must be separated by semicolons, The property name and its value should be separated by a colon. Each declaration should be terminated by a semicolon (;).
Eg:
Samacheer Kalvi 11th Computer Applications Solutions Chapter 13 CSS - Cascading Style Sheets

Question 3.
Wrie a CSS file to define text color and alignment to <p> tag?
Answer:
The style properties are defined to <p> tag. Hereafter, whenever you use the <p>, the contents will be displayed with modified properties.

If you want to use the above style definition as an internal style then it should be specified within <style>,</style> block in head section. If you want store the above definition for using all your web pages, you should save the above code as a separate file with extension.css

Samacheer Kalvi 11th Computer Applications Solutions Chapter 13 CSS - Cascading Style Sheets

Question 4.
Write a CSS file to define font type, style and size to <h1> tag?
Answer:
<h1> tag in a particular font style and size with blue colour in the entire page,You can use <style> tag to define its properties in head section. The style of <h1> header tag is clearly defined. So, hereafter, the content between <h1> and </h1> will be displayed as per its definition.

IV. Answer To The Following Questions

Question 1.
Write an HTML document to display the following oaragraph as per the given description Using CSS:
Font Name:
Cooper Black

Style:
Bold Italics

Color:
Blue “The State Institute of Education (SIE) was established in 1965 to provide for systematic study of problems relating to School Education under the administration of Directorate of School Education.”

Samacheer Kalvi 11th Computer Applications Solutions Chapter 13 CSS - Cascading Style Sheets

Question 2.
List and explain the Font and text element properties and values used CSS?
Answer:
Samacheer Kalvi 11th Computer Applications Solutions Chapter 13 CSS - Cascading Style Sheets

Samacheer Kalvi 11th Computer Applications HTML – Adding Multimedia Elements and Forms Additional Questions and Answers

I. Choose The Correct Answer

Question 1.
Which tag is used to change the default characteristics of web document?
(a) Style
(b) Font
(c) Text
(d) Colour
Answer:
(a) Style

Samacheer Kalvi 11th Computer Applications Solutions Chapter 13 CSS - Cascading Style Sheets

Question 2.
Which is used to define style for a particular tag anywhere in a HTML document?
(a) Internal style
(b) Inline style
(c) External style
(d) Page style
Answer:
(b) Inline style

Question 3.
CSS was invented by:
(a) Hakon Wium Lie
(b) Hakon Willium Lee
(c) Hakon Street Man
(d) Hakon Lee
Answer:
(a) Hakon Wium Lie

Question 4.
The <style> tag are also called as:
(a) page-level styles
(b) inline styles
(c) external styles
(d) both (a) & (c)
Answer:
(a) page-level styles

Samacheer Kalvi 11th Computer Applications Solutions Chapter 13 CSS - Cascading Style Sheets

Question 5.
Which section is used by the <link> tag to add CSS file?
(a) Body
(b) Head
(c) Style
(d) Title
Answer:
(b) Head

Samacheer Kalvi 11th Computer Applications Solutions Chapter 13 CSS - Cascading Style Sheets

Question 6.
Expand XHTML:
(a) Extensible Hypertext Markup Language
(b) Extended Hypertext Markup Language
(c) Executed Hypertext Markup Language
(d) Except Hypertext Markup Language
Answer:
(a) Extensible Hypertext Markup Language

II. Answer The Following Questions

Question 1.
What is called page-level sheets or internal sheets?
Answer:
The <style> tag controls the presentation styles of a particular HTML document. If you want to use a particular tag with the same style applied in one HTML document to another is not possible. Thus, the <style> tags are called as “Page-Level Styles” or “Internal Style sheets”.

Samacheer Kalvi 11th Computer Applications Solutions Chapter 13 CSS - Cascading Style Sheets

Question 2.
What is known as sitewide style sheets or external style sheets?
Answer:
The “Internal Style Sheet” is defined and implemented only within an HTML document. If you want use the same style to multiple pages, you should define styles as a separate style file. These separate style files are known as “Sitewide Style Sheets” or ‘”External Style Sheets”.

III. Answer The Following Questions

Question 1.
Write the suitable example for creating CSS style?
Answer:
P {
font-style : Italic;
color :MediumSeaGreen;
}
H1
{
border: 2px solid red;
}
The above code should be saved with extension. css

Samacheer Kalvi 11th Computer Applications Solutions Chapter 13 CSS - Cascading Style Sheets

Question 2.
Write the properties and values of paragraph margin in CSS?
Answer:
Samacheer Kalvi 11th Computer Applications Solutions Chapter 13 CSS - Cascading Style Sheets

IV. Answer The Following Questions

Question 1.
Write the html code to change the background colour of browser using CSS?
Answer:
– Back_Color.css —
body
{
background-color : pink;
}
Background_CSS.htm
<html>
<head>
<title> Changing Background using CSS </title>
<link rel = “stylesheet” type=”text/css” href=”Body_Color.css”> </head>
<body>
<H1> Welcome to CSS
</H1>
</body>
</html>

Samacheer Kalvi 12th Computer Science Solutions Chapter 7 Python Functions

Students can Download Computer Science Chapter 7 Python Functions Questions and Answers, Notes Pdf, Samacheer Kalvi 12th Computer Science Book Solutions Guide Pdf helps you to revise the complete Tamilnadu State Board New Syllabus and score more marks in your examinations.

Tamilnadu Samacheer Kalvi 12th Computer Science Solutions Chapter 7 Python Functions

Samacheer Kalvi 12th Computer Science Python Functions Text Book Back Questions and Answers

PART – I
I. Choose The Best Answer

Question 1.
A named blocks of code that are designed to do one specific job is called as …………………………
(a) Loop
(b) Branching
(c) Function
(d) Block
Answer:
(c) Function

Question 2.
A Function which calls itself is called as …………………………
(a) Built – in
(b) Recursion
(c) Lambda
(d) Return
Answer:
(b) Recursion

Samacheer Kalvi 12th Computer Science Solutions Chapter 7 Python Functions

Question 3.
Which function is called anonymous un – named function?
(a) Lambda
(b) Recursion
(c) Function
(d) Define
Answer:
(a) Lambda

Question 4.
Which of the following keyword is used to begin the function block?
(a) Define
(b) For
(c) Finally
(d) Def
Answer:
(d) Def

Question 5.
Which of the following keyword is used to exit a function block?
(a) Define
(b) Return
(c) Finally
(d) Def
Answer:
(b) Return

Samacheer Kalvi 12th Computer Science Solutions Chapter 7 Python Functions

Question 6.
While defining a function which of the following symbol is used.
(a) ; (semicolon)
(b) . (dot)
(c) : (colon)
(d) $ (dollar)
Answer:
(c) : (colon)

Question 7.
In which arguments the correct positional order is passed to a function?
(a) Required
(b) Keyword
(c) Default
(d) Variable – length
Answer:
(a) Required

Samacheer Kalvi 12th Computer Science Solutions Chapter 7 Python Functions

Question 8.
Read the following statement and choose the correct statement(s).
(I) In Python, you don’t have to mention the specific data types while defining function.
(II) Python keywords can be used as function name.

(a) (I) is correct and (II) is wrong
(b) Both are correct
(c) (I) is wrong and (II) is correct
(d) Both are wrong
Answer:
(a) (I) is correct and (II) is wrong

Question 9.
Pick the correct one to execute the given statement successfully.
if_: print (x,” is a leap year”)
(a) x % 2 = 0
(b) x % 4 = = 0
(c) x / 4 = 0
(d) x % 4 = 0
Answer:
(b) x % 4 = = 0

Samacheer Kalvi 12th Computer Science Solutions Chapter 7 Python Functions

Question 10.
Which of the following keyword is used to define the function testpython():?
(a) Define
(b) Pass
(c) Def
(d) While
Answer:
(c) Def

PART – II
II. Answer The Following Questions

Question 1.
What is function?
Answer:
Functions are named blocks of code that are designed to do specific job. If you need to perform that task multiple times throughout your program, you just call the function dedicated to handling that task.

Question 2.
Write the different types of function?
Answer:

  1. User – defined Functions
  2. Built – in Functions
  3. Lambda Functions
  4. Recursion Functions

Samacheer Kalvi 12th Computer Science Solutions Chapter 7 Python Functions

Question 3.
What are the main advantages of function?
Answer:
Main advantages of functions are:

  1. It avoids repetition and makes high degree of code reusing.
  2. It provides better modularity for your application.

Question 4.
What is meant by scope of variable? Mention its types?
Answer:
Scope of variable refers to the part of the program, where it is accessible, i.e., area where you can refer (use) it. We can say that scope holds the current set of variables and their values. The two types of scopes are: local scope and global scope.

Question 5.
Define global scope?
Answer:
A variable, with global scope can be used anywhere in the program. It can be created by defining a variable outside the scope of any function/block.

Samacheer Kalvi 12th Computer Science Solutions Chapter 7 Python Functions

Question 6.
What is base condition in recursive function?
Answer:
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.

Question 7.
How to set the limit for recursive function? Give an example?
Answer:
Python also allows you to change the limit using sys.setrecursionlimit (limit value).
Example:
import sys
sys.setrecursionlimit(3000)
def fact (n):
if n = = 0:
return 1
else:
return n * fact (n – 1)
print (fact (2000))

PART – III
III. Answer The Following Questions

Question 1.
Write the rules of local variable?
Answer:
Rules of local variable:

  1. A variable with local scope can be accessed only within the function/block that it is created in.
  2. When a variable is created inside the function/block, the variable becomes local to it.
  3. A local variable only exists while the function is executing.
  4. The formate arguments are also local to function.

Samacheer Kalvi 12th Computer Science Solutions Chapter 7 Python Functions

Question 2.
Write the basic rules for global keyword in python?
Answer:
The basic rules for global keyword in Python are:

  1. When we define a variable outside a function, it’s global by default. You don’t have to use global keyword.
  2. We use global keyword to read and write a global variable inside a function.
  3. Use of global keyword outside a function has no effect

Samacheer Kalvi 12th Computer Science Solutions Chapter 7 Python Functions

Question 3.
What happens when we modify global variable inside the function?
Answer:
It will change the global variable value outside the function also.

Question 4.
Differentiate ceil ( ) and floor ( ) function?
Answer:
Samacheer Kalvi 12th Computer Science Solutions Chapter 7 Python Functions

Question 5.
Write a Python code to check whether a given year is leap year or not?
Leap year or not:
Program code:
Answer:
n = int (input(“Enter any year”))
if (n % 4 = = 0):
print “Leap year”
else:
print “Not a Leap year”
Output:
Enter any year 2001
Not a Leap year

Samacheer Kalvi 12th Computer Science Solutions Chapter 7 Python Functions

Question 6.
What is composition in functions?
Answer:
The value returned by a function may be used as an argument for another function in a nested manner. This is called composition. For example, if we wish to take a numeric value or an expression as a input from the user, we take the input string from the user using the function input ( ) and apply eval ( ) function to evaluate its value.

Question 7.
How recursive function works?
Answer:

  1. Recursive function is called by some external code.
  2. If the base condition is met then the program gives meaningful output and exits.
  3. Otherwise, function does some required processing and then calls itself to continue recursion.

Samacheer Kalvi 12th Computer Science Solutions Chapter 7 Python Functions

Question 8.
What are the points to be noted while defining a function?
Answer:

  1. Function blocks begin with the keyword “def ” followed by function name and parenthesis ( ).
  2. Any input parameters or arguments should be placed within these parentheses when you define a function.
  3. The code block always comes after a colon (:) and is indented.
  4. The statement “return [expression]” exits a function, optionally passing back an expression to the caller. A “return” with no arguments is the same as return None

PART – IV
IV. Answer The Following Questions

Question 1.
Explain the different types of function with an example?
Answer:
Types of Functions:
Basically, we can divide functions into the following types:

  1. User – defined Functions
  2. Built – in Functions
  3. Lambda Functions
  4. Recursion Functions

Functions:
User – defined functions
Built – in functions
Lambda functions
Recursion functions

Description:
Functions defined by the users themselves.
Functions that are inbuilt with in Python.
Functions that are anonymous un-named function.
Functions that calls itself is known as recursive.

(I) Syntax for User defined function
def <function_name ( [parameter1, parameter!…] ) > :
<Block of Statements> return <expression /None>
Example:
def hello ( ):
print (“hello – Python”)
return

Advantages of User – defined Functions:

  1. Functions help us to divide a program into modules. This makes the code easier to manage.
  2. It implements code reuse. Every time you need to execute a sequence of statements, all you need to do is to call the function.
  3. Functions, allows us to change functionality easily, and different programmers can work on different functions.

(II) Anonymous Functions:
In Python, anonymous function is a function that is defined without a name. While normal functions are defined using the def keyword, in Python anonymous functions are defined using the lambda keyword. Hence, anonymous functions are also called as lambda functions.

The use of lambda or anonymous function:

  1. Lambda function is mostly used for creating small and one-time anonymous function.
  2. Lambda functions are mainly used in combination with the functions like filter ( ), map ( ) and reduce ( ).

Syntax of Anonymous Functions
The syntax for anonymous functions is as follows:
lambda [argument(s)] expression
Example:
sum = lambda argl, arg2: argl + arg2
print (‘The Sum is sum (30, 40))
print (‘The Sum is :’, sum (-30, 40))
Output:
The Sum is: 70
The Sum is: 10
The above lambda function that adds argument argl with argument arg2 and stores the result in the variable sum. The result is displayed using the print ( ).

(III) Functions using libraries:
Built – in and Mathematical functions
Samacheer Kalvi 12th Computer Science Solutions Chapter 7 Python Functions

(IV) Recursive functions:
When a function calls itself is known as recursion. Recursion works like loop but sometimes 1 ’ it makes more sense to use recursion than loop. You can convert any loop to recursion.
Example:
def fact(n):
if n = = 0:
return 1
else:
return n * fact (n – 1)
print (fact (0))
print (fact (5))
Output:
1
120

Samacheer Kalvi 12th Computer Science Solutions Chapter 7 Python Functions

Question 2.
Explain the scope of variables with an example?
Answer:
Scope of Variables:
Scope of variable refers to the part of the program, where it is accessible, i.e., area where you can refer (use) it. We can say that scope holds the current set of variables and their values.
The two types of scopes are local scope and global scope.

(I) Local scope:
A variable declared inside the function’s body or in the local scope is called as local variable.

Rules of local variable:

  1. A variable with local scope can be accessed only within the function/block that it is created in.
  2. When a variable is created inside the function/block; the variable becomes local to it.
  3. A local variable only exists while the function is executing.
  4. The formate arguments are also local to function.

Example: Create a Local Variable
def loc ( ):
y = 0 # local scope
print (y)
loc ( )
Output:
0
(II) Global Scope:
A variable, with global scope can be used anywhere in the program. It can be created by defining a variable outside the scope of any function/block.

Rules of global Keyword:
The basic rules for global keyword in Python are:

  1. When we define a variable outside a function, it’s global by default. You don’t have to useglobal keyword.
  2. We use global keyword to read and write a global variable inside a function.
  3. Use of global keyword outside a function has no effect

Example: Global variable and Local variable with same name
x = 5 def loc ( ):
x = 10
print (“local x:”, x)
loc ( )
print (“global x:”, x)
Output:
local x: 10
global x: 5
In above code, we used same name ‘x’ for both global variable and local variable. We get different result when we print same variable because the variable is declared in both scopes, i.e. the local scope inside the function loc() and global scope outside the function loc ( ).
The output:- local x: 10, is called local scope of variable.
The output: – global x: 5, is called global scope of variable.

Samacheer Kalvi 12th Computer Science Solutions Chapter 7 Python Functions

Question 3.
Explain the following built-in functions?
(a) id ( )
(b) chr ( )
(c) round ( )
(d) type ( )
(e) pow ( )
Answer:
Samacheer Kalvi 12th Computer Science Solutions Chapter 7 Python Functions
Samacheer Kalvi 12th Computer Science Solutions Chapter 7 Python Functions
Samacheer Kalvi 12th Computer Science Solutions Chapter 7 Python Functions

Question 4.
Write a Python code to find the L.C.M. of two numbers?
Answer:
Method I using functions:
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 + = 1
return lcm
num 1 = int (input(“Enter first number : “))
num 2 = int (input(“Enter second number : “))
print (“The L.C.M of”, numl, “and”, num, “is”, lcm(num1, num2))

Method II
(without using functions)
a = int (input (“Enter the first number :”))
b = int (input (“Enter the second number :”))
if a > b:
mini = a
else:
min 1 = b
while(1):
if (min 1 % a = = 0 and mini 1 % b = = 0):
print (“LCM is:”, mini)
break
mini = min 1 + 1
Output:
Enter the first number: 15
Enter the second number: 20
LCM is: 60

Samacheer Kalvi 12th Computer Science Solutions Chapter 7 Python Functions

Question 5.
Explain recursive function with an example?
Answer:
Python recursive functions
When a function calls itself is known as recursion. Recursion works like loop but sometimes it makes more sense to use recursion than loop. You can convert any loop to recursion.
A recursive function calls itself. Imagine a process would iterate indefinitely if not stopped by some condition! Such a process is known as infinite iteration. 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.

Working Principle:

  1. Recursive function is called by some external code.
  2. If the base condition is met then the program gives meaningful output and exits.
  3. Otherwise, function does some required processing and then calls itself to continue recursion. Here is an example of recursive function used to calculate factorial.

Example:
def fact (n):
if n = = 0:
return 1
else:
return n * fact (n – 1)
print (fact (0))
print (fact (5))
Output:
1
120

Practice Programs

Question 1.
Try the following code in the above program?
Answer:
Samacheer Kalvi 12th Computer Science Solutions Chapter 7 Python Functions
Output:
1. Error

2. Name: Sri
Salary: 3500
Salary: 3500

3. Name: Balu
Salary: 3500

4. Name: Jose
Salary: 1234

5. Name:
Salary: 1234

Samacheer Kalvi 12th Computer Science Solutions Chapter 7 Python Functions

Question 2.
Evaluate the following functions and write the output?
Answer:
Samacheer Kalvi 12th Computer Science Solutions Chapter 7 Python Functions
Output:

  1. 30
  2. 9
  3. 8
  4. 9

Question 3.
Evaluate the following functions and write the output?
Answer:
Samacheer Kalvi 12th Computer Science Solutions Chapter 7 Python Functions
Samacheer Kalvi 12th Computer Science Solutions Chapter 7 Python Functions
Output:
(i) 1. 13
2. 3.2

(ii) 1. 50
2. 36

(iii) <class ‘str’>

(iv) 0b10000

(v). 1. CR (carriage return)
2. It moves the cursor to the beginning of same line

(vi) 1. 8.2
2. 18.0
3. 0.510
4. 0.512

(vii) 1. B
2. a
3. A
4. 6
5. 10

(viii) 1. 0.125
2. 8.0
3. 1

Samacheer kalvi 12th Computer Science Python Functions Additional Questions and Answers

PART – 1
I. Choose The Best Answer

Question 1.
Name of the function is followed by ………………………….
(a) ( )
(b) [ ]
(c) <>
(d) { }
Answer:
(a) ( )

Question 2.
A …………………………. is one or more lines of code, grouped together.
(a) Code –
(b) Block
(c) Function
(d) Arguments
Answer:
(b) Block

Samacheer Kalvi 12th Computer Science Solutions Chapter 7 Python Functions

Question 3.
A block of code begins when a line is indented by ……………………. spaces usually.
(a) 2
(b) 3
(c) 4
(d) 5
Answer:
(c) 4

Question 4.
A block within a block is called …………………………… block.
Answer:
Nested

Samacheer Kalvi 12th Computer Science Solutions Chapter 7 Python Functions

Question 5.
If the return has no argument, …………………………….. will be displayed as the last statement of the output.
(a) No
(b) None
(c) Nothing
(d) No value
Answer:
(b) None

Question 6.
How many types of functions arguments are there?
(a) 2
(b) 3
(c) 4
(d) 5
Answer:
(c) 4

Question 7.
The arguments can be given in improper order in ………………………. arguments.
(a) Required
(b) Keyword
(c) Default
(d) Variable – length
Answer:
(b) Keyword

Samacheer Kalvi 12th Computer Science Solutions Chapter 7 Python Functions

Question 8.
What is the symbol used to denote variable – length arguments?
(a) +
(b) *
(c) &
(d) ++
Answer:
(b) *

Question 9.
How many methods of arguments passing are there in variable length method.
(a) 2
(b) 3
(c) 4
(d) 5
Answer:
(a) 2

Question 10.
Non – keyword variable arguments are called ……………………………….
Answer:
Tuples

Samacheer Kalvi 12th Computer Science Solutions Chapter 7 Python Functions

Question 11.
In python’s ……………………….. function supports variable length arguments.
(a) Input
(b) Write
(c) Output
(d) Print
Answer:
(d) Print

Question 12.
Lambda functions cannot be used in combination with ………………………….
(a) Filter
(b) Map
(c) Print
(d) Reduce
Answer:
(c) Print

Question 13.
Lambda function can only access ……………………….. variables.
(a) Local
(b) Function
(c) Global
(d) Nested
Answer:
(c) Global

Samacheer Kalvi 12th Computer Science Solutions Chapter 7 Python Functions

Question 14.
How many types of scopes are there?
(a) 2
(b) 3
(c) 4
(d) 5
Answer:
(a) 2

Question 15.
Find the correct one:
(a) Global keyword outside the function has no effect
(b) Global keyword outside the function has effect
Answer:
(a) Global keyword outside the function has no effect

Question 16.
Read the following statement and choose the wrong statements
(a) Without using the global keyword, we cannot modify the global variable
(b) Using global keyword we can modify the global variable
(c) Without global keyword, we can modify the global variable
Answer:
(c) Without global keyword, we can modify the global variable

Samacheer Kalvi 12th Computer Science Solutions Chapter 7 Python Functions

Question 17.
Find the correct statement.
(a) Local and global variables cannot be used in the same code
(b) Local and global variables can be used in the same code
Answer:
(b) Local and global variables can be used in the same code

Question 18.
The ……………………… function is the inverse of chr ( ) function.
(a) Ord ( )
(b) Abs ( )
(c) Chr ( )
(d) Bin ( )
Answer:
(a) Ord ( )

Samacheer Kalvi 12th Computer Science Solutions Chapter 7 Python Functions

Question 19.
…………………………. function is the alternative for bin ( ) function.
(a) Ord ( )
(b) Format ( )
(c) Binary ( )
(d) Ord ( )
Answer:
(b) Format ( )

Question 20.
bin ( ) returns the binary string prefixed with ………………………… for the given integer number
(a) b
(b) ob
(c) obin
(d) bin
Answer:
(b) ob

Question 21.
Find the output.
d = 43
print(‘A =ord(d))
(a) 67
(b) 95
(c) 97
(d) 65
Answer:
(d) 65

Samacheer Kalvi 12th Computer Science Solutions Chapter 7 Python Functions

Question 22.
Find the output,
d = 43
print (chr(d))
(a) –
(b) +
(c) *
(d) /
Answer:
(b) +

Question 23.
The default precision for fixed point number is ………………………….
(a) 2
(b) 4
(c) 6
(d) 8
Answer:
(c) 6

Samacheer Kalvi 12th Computer Science Solutions Chapter 7 Python Functions

Question 24.
How many formats are there for the format ( ) functions?
(a) 12
(b) 5
(c) 3
(d) 1
Answer:
(c) 3

Question 25.
………………………. function returns the smallest integer greater than or equal to x
(a) Sqrt
(b) Flow
(c) Floor
(d) Cell
Answer:
(d) Cell

Question 26.
………………………. function is used to evaluate the input value.
(a) Input
(b) Valuate
(c) Eval
(d) Val
Answer:
(c) Eval

Samacheer Kalvi 12th Computer Science Solutions Chapter 7 Python Functions

Question 27.
Any Loop can be converted to recursive functions.
True / False
Answer:
True

Question 28.
Find true statement
(a) Recursive function call itself
(b) Recursive function have to be called externally
Answer:
(a) Recursive function call itself

PART – II
II. Answer The Following Questions.

Question 1.
Define nested blocks?
Answer:
Nested Block:
A block within a block is called nested block. When the first block statement is indented by a single tab space, the second block of statement is indented by double tab spaces.

Samacheer Kalvi 12th Computer Science Solutions Chapter 7 Python Functions

Question 2.
Give the syntax for passing parameters in functions?
Answer:
Parameters or arguments can be passed to functions
def function _ name (parameter (s) separated by comma):

Question 3.
Differentiate parameters and arguments?
Answer:
Parameters are the variables used in the function definition whereas arguments are the values we pass to the function parameters.

Question 4.
Classify Function Arguments?
Function Arguments:

  1. Required arguments
  2. Keyword arguments
  3. Default arguments
  4. Variable – length arguments

Samacheer Kalvi 12th Computer Science Solutions Chapter 7 Python Functions

Question 5.
Define default arguments?
Answer:
Default Arguments
In Python the default argument is an argument that takes a default value if no value is provided in the function call. The following example uses default arguments, that prints default salary when no argument is passed, def printinfo(sal=3500):

Question 6.
What are the two methods of passing arguments in variable length arguments?
Answer:
In Variable Length arguments we can pass the arguments using two methods.

  1. Non keyword variable arguments
  2. Keyword variable arguments

PART – III
III. Answer The Following Questions.

Question 1.
Write the output for the program given below?
Answer:
Program:
def printdata (name, age):
print (“Example – 3 Keyword arguments”)
print (“Name :”,name)
print (“Age age)
return
# Now you can call printdata ( ) function
printdata (age = 25, name = “Gshan”)
Output:
Example – 3 Keyword arguments
Name: Gshan
Age: 25

Samacheer Kalvi 12th Computer Science Solutions Chapter 7 Python Functions

Question 2.
Give the syntax for defining variable – length arguments.?
Syntax – Variable – Length Arguments:
Answer:
def function _name (*args):
function_body
return_statement

Question 3.
Write note on return statement?
Answer:
The return Statement
1. The return statement causes your function to exit and returns a value to its caller. The point of functions in general is to take inputs and return something.

2. The return statement is used when a function is ready to return a value to its caller. So, only one return statement is executed at run time even though the function contains multiple return statements.

3. Any number of ‘return’ statements are allowed in a function definition but only one of them is executed at run time.

Samacheer Kalvi 12th Computer Science Solutions Chapter 7 Python Functions

Question 4.
Find the output?
Answer:
Program:
Answer:
x = 0 # global variable
def add ( ):
global x
x = x + 5 # increment by 2
print (“Inside add ( ) function x value is:”, x)
add ( )
print (“In main x value is x)
Output:
Inside add ( ) function x value is: 5.
In main x value is: 5

Samacheer Kalvi 12th Computer Science Solutions Chapter 7 Python Functions

Question 5.
Write note on format function?
Answer:
Samacheer Kalvi 12th Computer Science Solutions Chapter 7 Python Functions

PART – IV
IV. Answer The Following Questions.

Question 1.
Write any 5 built in functions?
Answer:
Samacheer Kalvi 12th Computer Science Solutions Chapter 7 Python Functions
Samacheer Kalvi 12th Computer Science Solutions Chapter 7 Python Functions

Samacheer Kalvi 12th Computer Science Solutions Chapter 3 Scoping

Students can Download Computer Science Chapter 3 Scoping Questions and Answers, Notes Pdf, Samacheer Kalvi 12th Computer Science Book Solutions Guide Pdf helps you to revise the complete Tamilnadu State Board New Syllabus and score more marks in your examinations.

Tamilnadu Samacheer Kalvi 12th Computer Science Solutions Chapter 3 Scoping

Samacheer Kalvi 12th Computer Science Scoping Text Book Back Questions and Answers

PART – 1
I. Choose The Best Answer

Question 1.
Which of the following refers to the visibility of variables in one part of a program to another part of the same program?
(a) Scope
(b) Memory
(c) Address
(d) Accessibility
Answer:
(a) Scope

Question 2.
The process of binding a variable name with an object is called ………………………….
(a) Scope
(b) Mapping
(c) Late binding
(d) Early binding
Answer:
(b) Mapping

Samacheer Kalvi 12th Computer Science Solutions Chapter 3 Scopingn

Question 3.
Which of the following is used in programming languages to map the variable and object?
(a) ::
(b) : =
(c) =
(d) = =
Answer:
(c) =

Question 4.
Containers for mapping names of variables to objects is called ………………………….
(a) Scope
(b) Mapping
(c) Binding
(d) Namespaces
Answer:
(d) Namespaces

Samacheer Kalvi 12th Computer Science Solutions Chapter 3 Scopingn

Question 5.
Which scope refers to variables defined in current function?
(a) Local Scope
(b) Global scope
(c) Module scope
(d) Function Scope
Answer:
(a) Local Scope

Question 6.
The process of subdividing a computer program into separate sub – programs is called ………………………….
(a) Procedural Programming
(b) Modular programming
(c) Event Driven Programming
(d) Object oriented Programming
Answer:
(b) Modular programming

Samacheer Kalvi 12th Computer Science Solutions Chapter 3 Scopingn

Question 7.
Which of the following security technique that regulates who canuse resources in a computing environment?
(a) Password
(b) Authentication
(c) Access control
(d) Certification
Answer:
(c) Access control

Question 8.
Which of the following members of a class can be handled only from within the class?
(a) Public members
(b) Protected members
(c) Secured members
(d) Private members
Answer:
(d) Private members

Samacheer Kalvi 12th Computer Science Solutions Chapter 3 Scopingn

Question 9.
Which members are accessible from outside the class?
(a) Public members
(b) Protected members
(c) Secured members
(d) Private members
Answer:
(a) Public members

Samacheer Kalvi 12th Computer Science Solutions Chapter 3 Scopingn

Question 10.
The members that are accessible from within the class and are also available to its subclasses is called ………………………….
(a) Public members
(b) Protected members
(c) Secured members
(d) Private members
Answer:
(b) Protected members

PART – II
II. Answer The Following Questions

Question 1.
What is a scope?
Answer:
Scope refers to the visibility of variables, parameters and functions in one part of a program to another part of the same program.

Question 2.
Why scope should be used for variable. State the reason?
Answer:
Essentially, variables are addresses (references, or pointers), to an object in memory. When you assign a variable with := to an instance (object), you’re binding (or mapping) the variable to that instance. Multiple variables can be mapped to the same instance.

Samacheer Kalvi 12th Computer Science Solutions Chapter 3 Scopingn

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

Question 4.
What do you mean by Namespaces?
Answer:
Programming languages keeps track of all these mappings with namespaces. Namespaces are containers for mapping names of variables to objects.

Samacheer Kalvi 12th Computer Science Solutions Chapter 3 Scopingn

Question 5.
How Python represents the private and protected Access specifiers?
Answer:
Private members of a class are denied access from the outside of the class. They can be handled only within the class.
Protected members of a class are accessible from within the class and are also available to its sub-classes. No other process is permitted access to it.

PART – III
III. Answer The Following Questions

Question 1.
Define Local scope with an example?
Answer:
Local Scope:
Local scope refers to variables defined in current function. Always, a function will first look up for a variable name in its local scope. Only if it does not find it there, the outer scopes are checked.
Look at this example
Samacheer kalvi 12th Computer Science Solutions Chapter 3 Scoping
On execution of the above code the variable a displays the value 7, because it is defined and available in the local scope.

Samacheer Kalvi 12th Computer Science Solutions Chapter 3 Scopingn

Question 2.
Define Global scope with an example?
Answer:
Global Scope:
A variable which is declared outside of all the functions in a program is known as global variable. This means, global variable can be accessed inside or outside of all the functions in a program. Consider the following example
Samacheer kalvi 12th Computer Science Solutions Chapter 3 Scoping
On execution of the above code the variable a which is defined inside the function displays the value 7 for the function call Disp( ) and then it displays 10, because a is defined in global scope.

Samacheer Kalvi 12th Computer Science Solutions Chapter 3 Scopingn

Question 3.
Define Enclosed scope with an example?
Answer:
Enclosed Scope:
All programming languages permit functions to be nested. A function (method) with in another function is called nested function. A variable which is declared inside a function which contains another function definition with in it, the inner function can also access the variable of the outer function. This scope is called enclosed scope. When a compiler or interpreter search for a variable in a program, it fist search Local, and then search Enclosing scopes. Consider the following example
Samacheer Kalvi 12th Computer Science Solutions Chapter 3 Scoping

Question 4.
Why access control is required?
Answer:
Access control is a security technique that regulates who or what can view or use resources in a computing environment.
It is a fundamental concept in security that minimizes risk to the object. In other words access control is a selective restriction of access to data.
In Object oriented programming languages it is implemented through access modifies.
Classical object – oriented languages, such as C++ and Java, control the access to class members by public, private and protected keywords.

Samacheer Kalvi 12th Computer Science Solutions Chapter 3 Scopingn

Question 5.
Identify the scope of the variables in the following pseudo code and write its output?
Answer:
Samacheer Kalvi 12th Computer Science Solutions Chapter 3 Scoping
Output:
Red, blue, green
Red blue
Red

PART – IV
IV. Answer The Following Questions

Question 1.
Explain the types of scopes for variable or LEGB rule with example?
Answer:
LEGB rule
Scope also defines the order in which variables have to be mapped to the object in order to obtain the value. Let us take a simple example as shown below:

  1. x: = ‘outer x variable’
  2. display ( ):
  3. x: = ‘inner x variable’
  4. print x
  5. display ( )

When the above statements are executed the statement (4) and (5) display the result as
Output
outer x variable
inner x variable
Above statements give different outputs because the same variable name x resides in different scopes, one inside the function display( ) and the other in the upper level. The value ‘outer x variable’ is printed when x is referenced outside the function definition. Whereas when display( ) gets executed, ‘inner x variable’ is printed which is the x value inside the function definition. From the above example, we can guess that there is a rule followed, in order to decide from which scope a variable has to be picked. The LEGB rule is used to decide the order in which the scopes are to be searched for scope resolution. The scopes are listed below in terms of hierarchy (highest to lowest).
Samacheer kalvi 12th Computer Science Solutions Chapter 3 Scoping
Samacheer Kalvi 12th Computer Science Solutions Chapter 3 Scoping

Types of Variable Scope:
There are 4 types of Variable Scope, let’s discuss them one by one:

Local Scope:
Local scope refers to variables defined in current function. Always, a function will first look up for a variable name in its local scope. Only if it does not find it there, the outer scopes are checked. Look at this example
Samacheer kalvi 12th Computer Science Solutions Chapter 3 Scoping
On execution of the above code the variable a displays the value 7, because it is defined and available in the local scope.

Global Scope:
A variable which is declared outside of all the functions in a program is known as global variable. This means, global variable can be accessed inside or outside of all the functions in a program. Consider the following example
Samacheer kalvi 12th Computer Science Solutions Chapter 3 Scoping
On execution of the above code the variable a which is defined inside the function displays the value 7 for the function call Disp( ) and then it displays 10, because a is defined in global scope.

Enclosed Scope:
All programming languages permit functions to be nested. A function (method) with in another function is called nested function. A variable which is declared inside a function which contains another function definition with in it, the inner function can also access the variable of the outer function. This scope is called enclosed scope. When a compiler or interpreter search for a variable in a program, it first search Local, and then search Enclosing scopes. Consider the following example
Samacheer Kalvi 12th Computer Science Solutions Chapter 3 Scoping
In the above example Disp1 ( ) is defined with in Disp ( ). The variable ‘a’ defined in Disp ( ) can be even used by Disp 1 ( ) because it is also a member of Disp

Built – in Scope:
Finally, we discuss about the widest scope. The built-in scope has all the names that are pre-loaded into the program scope when we start the compiler or interpreter. Any variable or module which is defined in the library functions of a programming language has Built-in or module scope. They are loaded as soon as the library files are imported to the program.
Samacheer Kalvi 12th Computer Science Solutions Chapter 3 Scoping
Normally only Functions or modules come along with the software, as packages. Therefore they will come under Built in scope.

Samacheer Kalvi 12th Computer Science Solutions Chapter 3 Scopingn

Question 2.
Write any Five Characteristics of Modules?
Answer:
Characteristics of Modules:
The following are the desirable characteristics of a module.

  1. Modules contain instructions, processing logic, and data.
  2. Modules can be separately compiled and stored in a library.
  3. Modules can be included in a program.
  4. Module segments can be used by invoking a name and some parameters.
  5. Module segments can be used by other modules.

Samacheer Kalvi 12th Computer Science Solutions Chapter 3 Scopingn

Question 3.
Write any five benefits in using modular programming?
Answer:
The benefits of using modular programming include:

  1. Less code to be written.
  2. A single procedure can be developed for reuse, eliminating the need to retype the code many times.
  3. Programs can be designed more easily because a small team deals with only a small part of the entire code.
  4. Modular programming allows many programmers to collaborate on the same application.
  5. The code is stored across multiple files.
  6. Code is short, simple and easy to understand.
  7. Errors can easily be identified, as they are localized to a subroutine or function.
  8. The same code can be used in many applications.
  9. The scoping of variables can easily be controlled.

Practice Programs

Question 1.
Observe the following diagram and Write the pseudo code for the following?
Answer:
Samacheer Kalvi 12th Computer Science Solutions Chapter 3 Scoping
sum ( ):
num 1: = 20
sum 1 ( )
num1: = num1 + 10 sum2 ( )
num1: = num1 + 10
sum2 ( ) sum1 ( ) num1: = 10
sum ( )
Print num 1

Samacheer kalvi 12th Computer Science Scoping Additional Questions and Answers

PART -1
I. Choose The Best Answer

Question 1.
Names paces are compared with ……………………….
(a) Programs
(b) Dictionaries
(c) Books
(d) Notebooks
Answer:
(b) Dictionaries

Question 2.
Write the output (value stored in b)
1. a: = 5
2. b: = a
(a) 0
(b) 3
(c) 5
(d) 2
Answer:
(c) 5

Samacheer Kalvi 12th Computer Science Solutions Chapter 3 Scopingn

Question 3.
Find the value of a.
1. a: = 5
2. b: = a
3. a: = 3
(a) 0
(b) 3
(c) 5
(d) 2
Answer:
(b) 3

Question 4.
The ………………………. of a variable is that part of the code where it is visible.
Answer:
Scope

Samacheer Kalvi 12th Computer Science Solutions Chapter 3 Scopingn

Question 5.
The duration for which a variable is alive is called its ……………………………
(a) Scale
(b) Life time
(c) Static
(d) Function
Answer:
(b) Life time

Question 6.
…………………………… also defines the order in which variables have to be mapped to the object in order to obtain the value.
(a) Scope
(b) Local
(c) Event
(d) Object
Answer:
(a) Scope

Question 7.
The …………………………… rule is used to decide the order in which the scopes are to be searched for scope resolution.
Answer:
LEGB

Samacheer Kalvi 12th Computer Science Solutions Chapter 3 Scopingn

Question 8.
How many types of variable scopes are there?
(a) 1
(b) 2
(c) 3
(d) 4
Answer:
(d) 4

Question 9.
A function will first look up for a variable name in its …………………………… scope.
(a) Local
(b) Enclosed
(c) Global
(d) Built in
Answer:
(a) Local

Samacheer Kalvi 12th Computer Science Solutions Chapter 3 Scopingn

Question 10.
A variable which is declared outside of all the functions in a program is known as …………………………… variable.
(a) L
(b) E
(c) G
(d) B
Answer:
(c) G

Question 11.
A …………………………… variable can be accessed inside or outside of all the functions in a program.
(a) Local
(b) Global
(c) Enclosed
(d) Built – in
Answer:
(b) Global

Question 12.
A function defined within another function is called …………………………… function
(a) Member
(b) Looping
(c) Nested
(d) Invariant
Answer:
(c) Nested

Samacheer Kalvi 12th Computer Science Solutions Chapter 3 Scopingn

Question 13.
Functions are otherwise called as …………………………..
(a) Methods
(b) Attributes
(c) Class
(d) Structures
Answer:
(a) Methods

Question 14.
The scope of nested function is …………………………… scope
(a) Local
(b) Global
(c) Enclosed
(d) Built – in
Answer:
(c) Enclosed

Question 15.
When a compiler or interpreter search for a variable in a program, it first search and then search …………………………… scope
(a) L, E
(b) EG
(c) GB
(d) BL
Answer:
(a) L, E

Samacheer Kalvi 12th Computer Science Solutions Chapter 3 Scopingn

Question 16.
Built – in scopes are called as …………………………… scope.
Answer:
Module

Question 17.
Any variable or module defined in the library functions has …………………………… scope.
Answer:
Built – in

Question 18.
Variables of built – in scopes are loaded as …………………………… files.
(a) Exe
(b) Linker
(c) Object
(d) Library
Answer:
(d) Library

Samacheer Kalvi 12th Computer Science Solutions Chapter 3 Scopingn

Question 19.
Identify which is not a variable scope.
(a) Module
(b) Built – in
(c) Enclosed
(d) Pointer
Answer:
(d) Pointer

Question 20.
A single …………………………… can contain one or several statements closely related to each other.
Answer:
Module

Question 21.
A …………………………… is a part of a program.
(a) Code
(b) Module
(c) Flowchart
(d) System software
Answer:
(b) Module

Question 22.
Identify which is not a module?
(a) Algorithm
(b) Procedures
(c) Subroutines
(d) Functions
Answer:
(a) Algorithm

Samacheer Kalvi 12th Computer Science Solutions Chapter 3 Scopingn

Question 23.
Find the wrong statement from the following
(a) Modules contains data and instructions
(b) Modules can be included in a program
(c) Modules cannot have processing logic
(d) Modules can be separately combined
Answer:
(c) Modules cannot have processing logic

Question 24.
Which is true about modular programming?
(a) Single procedure can be reused
(b) Single procedure cannot be reused
Answer:
(a) Single procedure can be reused

Samacheer Kalvi 12th Computer Science Solutions Chapter 3 Scopingn

Question 25.
The arrangement of private instance variables and public methods ensures the principle of ……………………………
(a) Security
(b) Data encapsulation
(c) Inheritance
(d) Class
Answer:
(b) Data encapsulation

Question 26.
All members in a python class are by …………………………… default.
(a) Private
(b) Public
(c) Protected
(d) Local
Answer:
(b) Public

Samacheer Kalvi 12th Computer Science Solutions Chapter 3 Scopingn

Question 27.
The members in C ++ and Java, by default are ……………………………
(a) Private
(b) Public
(c) Protected
(d) Local
Answer:
(a) Private

PART – II
II. Answer The Following Questions

Question 1.
Define life time?
Answer:
The duration for which a variable is alive is called its ‘life time’.

PART – III
III. Answer The Following Questions

Question 1.
Write the output for the pseudo code?
Answer:

  1. x: = ‘outer x variable’
  2. display( ):
  3. x: = ‘inner x variable’
  4. print x
  5. display Q

Output:
outer x variable
inner x variable

Samacheer Kalvi 12th Computer Science Solutions Chapter 3 Scopingn

Question 2.
List the scope in hierarchical order from highest to lowest?
Answer:
Samacheer Kalvi 12th Computer Science Solutions Chapter 3 Scoping
Samacheer Kalvi 12th Computer Science Solutions Chapter 3 Scoping

Question 3.
Write note on modules?
Answer:
A module is a part of a program. Programs are composed of one or more independently developed modules. A single module can contain one or several statements closely related each other. Modules work perfectly on individual level and can be integrated with other modules.

Samacheer Kalvi 12th Computer Science Solutions Chapter 3 Scopingn

Question 4.
Write note on public members?
Answer:
Public members (generally methods declared in a class) are accessible from outside the class. The object of the same class is required to invoke a public method. This arrangement of private instance variables and public methods ensures the principle of data encapsulation.

Samacheer Kalvi 12th Computer Science Solutions Chapter 8 Strings and String Manipulations

Students can Download Computer Science Chapter 8 Strings and String Manipulations Questions and Answers, Notes Pdf, Samacheer Kalvi 12th Computer Science Book Solutions Guide Pdf helps you to revise the complete Tamilnadu State Board New Syllabus and score more marks in your examinations.

Tamilnadu Samacheer Kalvi 12th Computer Science Solutions Chapter 8 Strings and String Manipulations

Samacheer Kalvi 12th Computer Science Strings and String Manipulations Text Book Back Questions and Answers

PART – I
I. Choose The Best Answer

Question 1.
Which of the following is the output of the following python code?
Answer:
str1=”TamilNadu”
print (str1 [:: -1])
(a) Tamilnadu
(b) Tmlau
(c) UdanlimaT
(d) UdaNlimaT
Answer:
(c) UdanlimaT

Question 2.
What will be the output of the following code?
Answer:
str1= “Chennai Schools”
str1[7] = “_”
(a) Chennai – Schools
(b) Chenna – School
(c) Type error
(d) Chennai
Answer:
(c) Type error

Samacheer Kalvi 12th Computer Science Solutions Chapter 8 Strings and String Manipulations

Question 3.
Which of the following operator is used for concatenation?
(a) +
(b) &
(c) *
(d) =
Answer:
(a) +

Question 4.
Defining strings within triple quotes allows creating:
(a) Single line Strings
(b) Multiline Strings
(c) Double line Strings
(d) Multiple Strings
Answer:
(b) Multiline Strings

Question 5.
Strings in python:
(a) Changeable
(b) Mutable
(c) Immutable
(d) Flexible
Answer:
(c) Immutable

Samacheer Kalvi 12th Computer Science Solutions Chapter 8 Strings and String Manipulations

Question 6.
Which of the following is the slicing operator?
(a) { }
(b) [ ]
(c) <>
(d) ( )
Answer:
(b) [ ]

Question 7.
What is stride?
(a) Index value of slide operation
(b) First argument of slice operation
(c) Second argument of slice operation
(d) Third argument of slice operation
Answer:
(d) Third argument of slice operation

Samacheer Kalvi 12th Computer Science Solutions Chapter 8 Strings and String Manipulations

Question 8.
Which of the following formatting character is used to print exponential notation in upper case?
(a) % e
(b) % E
(c) % g
(d) % n
Answer:
(b) % E

Question 9.
Which of the following is used as placeholders or replacement fields which get replaced along with format ( ) function?
(a) { }
(b) <>
(c) ++
(d) ^^
Answer:
(a) { }

Samacheer Kalvi 12th Computer Science Solutions Chapter 8 Strings and String Manipulations

Question 10.
The subscript of a string may be:
(a) Positive
(b) Negative
(c) Both (a) and (b)
(d) Either (a) or (b)
Answer:
(d) Either (a) or (b)

PART – II
II. Answer The Following Questions

Question 1.
What is String?
Answer:
String is a data type in python, which is used to handle array of characters. String is a sequence of Unicode characters that may be a combination of letters, numbers, or special symbols enclosed within single, double or even triple quotes.
Example:
‘Welcome to learning Python’
“Welcome to learning Python”
“Welcome to learning Python”

Samacheer Kalvi 12th Computer Science Solutions Chapter 8 Strings and String Manipulations

Question 2.
Do you modify a string in Python?
Answer:
If you want to modify the string, a new string value can be assign to the existing string variable. To define a new string value to the existing string variable. Python completely overwrite new string on the existing string.
Example:
>>> str1=”How are you”
>>> print (str1)
How are you
>>> str1=”How about you”
>>> print (str1)
How about you

Samacheer Kalvi 12th Computer Science Solutions Chapter 8 Strings and String Manipulations

Question 3.
How will you delete a string in Python?
Answer:
Python will not allow deleting a particular character in a string. Whereas you can remove entire string variable using del command.
Example: Code lines to delete a string variable
>>> str1=”How about you”
>>> print (str1)
How about you
>>> del str1
>>> print (str1)
NameError: name ‘str1’ is not defined

Question 4.
What will be the output of the following python code?
Answer:
str1 = “School”
print (str1*3)
Output:
School School School

Samacheer Kalvi 12th Computer Science Solutions Chapter 8 Strings and String Manipulations

Question 5.
What is slicing?
Answer:
String slicing:
Slice is a substring of a main string. A substring can be taken from the original string by using [ ] operator and index or subscript values. Thus, [ ] is also known as slicing operator. Using slice operator, we can slice one or more substrings from a main string.

General format of slice operation:
str[start:end]
Where start is the beginning index and end is the last index value of a character in the string. Python takes the end value less than one from the actual index specified. For example, if you want to slice first 4 characters from a string, you have to specify it as 0 to 5. Because, python consider only the end value as n – 1.
Example: slice a single character from a string
>>> str1=”THIRUKKURAL”
>>> print (str1[0])
T

PART – III
III. Answer The Following Questions

Question 1.
Write a Python program to display the given pattern?
Answer:
C O M P U T E R
C O M P U T E
C O M P U T
C O M P U
C O M P
C O M
C O
C
Program:
str1 = “COMPUTER”
index = len (str1)
for i in str 1:
print (str 1[: index])
index – = 1

Samacheer Kalvi 12th Computer Science Solutions Chapter 8 Strings and String Manipulations

Question 2.
Write a short about the followings with suitable example?
Answer:
Samacheer Kalvi 12th Computer Science Solutions Chapter 8 Strings and String Manipulations

Question 3.
What will be the output of the given python program?
str1 = “welcome”
str2 = “to school”
str3 = str1[: 2] str2[len(str2)-2:]
print (str3)
output:
Answer:
weoo 1

Samacheer Kalvi 12th Computer Science Solutions Chapter 8 Strings and String Manipulations

Question 4.
What is the use of format( )? Give an example?
Answer:
The format( ) function used with strings is very versatile and powerful function used for formatting strings. The curly braces { } are used as placeholders or replacement fields which get replaced along with format( ) function.
Example:
num1 = int (input (“Number 1: “))
num2 = int (input (“Number 2: “))
print (“The sum of { } and { } is { }”.format (num1, num2,(num1 + num2)))
OutPut:
Number 1 : 34
Number 2 : 54
The sum of 34 and 54 is 88.

Question 5.
Write a note about count ( ) function in python?
Answer:
Samacheer Kalvi 12th Computer Science Solutions Chapter 8 Strings and String Manipulations

PART – IV
IV. Answer The Following Questions.

Question 1.
Explain about string operators in python with suitable example?
Answer:
String Operators:
Python provides the following operators for string operations. These operators are useful to manipulate string.

(i) Concatenation (+):
Joining of two or more strings is called as Concatenation. The plus (+) operator is used to concatenate strings in python.
Example:
>>> “welcome” + “Python”
‘welcomePython’

(ii) Append (+=):
Adding more strings at the end of an existing string is known as append. The operator += is used to append a new string with an existing string.
Example:
>>> str1 =”Welcome to ”
>>> str1+=”Leam Python”
>>> print (str1)
Welcome to Learn Python

(iii) Repeating (*):
The multiplication operator (*) is used to display a string in multiple number of times.
Example:
>>> str1 =”Welcome”
>>> print (str1*4)
Welcome Welcome Welcome Welcome

(iv) String slicing:
Slice is a substring of a main string. A substring can be taken from the original string by using [ ] operator and index or subscript values. Thus, [ ] is also known as slicing operator. Using slice operator, you have to slice one or more substrings from a main string.
General format of slice operation:
str[start: end]
Where start is the beginning index and end is the last index value of a character in the string. Python takes the end value less than one from the actual index specified. For example, if you want to slice first 4 characters from a string, you have to specify it as 0 to 5. Because, python consider only the end value as n – 1.
Example:
(i) slice a single character from a string
>>> str1=”THIRUKKURAL ”
>>> print (str1 [0])
T .

(v) Stride when slicing string
When the slicing operation, you can specify a third argument as the stride, which refers to the number of characters to move forward after the first character is retrieved from the string. The default value of stride is 1.
Example:
>>> str1= “Welcome to learn Python”
>>> print (str1 [10:16])
learn
Note: Remember that, python takes the last value as n – 1
You can also use negative value as stride (third argument). If you specify a negative value, it prints in reverse order.
Example:
>>> str1 = “Welcome to learn Python”
>>> print(str1 [::-2])
nhy re teoIW

Practice Programs

Question 1.
Write a python program to find the length of a string?
Answer:
str=input (“Enter a string: “)
print (len(str))
Output:
Enter a string: HELLO
5

Samacheer Kalvi 12th Computer Science Solutions Chapter 8 Strings and String Manipulations

Question 2.
Write a program to count the occurrences of each word in a given string?
Answer:
def word_count(str):
counts = dict ( )
words = str.split ( ) for word in words:
if word in counts:
counts[word] +=1
else:
counts[word]=1
return counts
print (word_count (‘the quick brown fox jumps over the lazy dog.’))
Ouput:
{‘the’: 2, ‘jumps’: 1, ‘brown’: 1, ‘lazy’: 1, ‘fox’: 1, ‘over’: 1, ‘quick’: 1, ‘dog’: 1}

Samacheer Kalvi 12th Computer Science Solutions Chapter 8 Strings and String Manipulations

Question 3.
Write a program to add a prefix text to all the lines in a string?
Answer:
import
text =
“‘Strings are immutable. Slice is a
substring of a main string. Stride
is a third argument in slicing operation'”
text_without_lndentation= textwrap.dedent (text)
wrapped = extwrap.fill (text_without_Indentation, width = 50)
print (textwrap.indent(wrapped, ‘*’)
print ()
Output:

  • Strings are immutable. Slice is a
  • substring of a main string. Stride
  • is a third argument in slicing operation

Question 4.
Write a program to print integers with ‘*’ on the right of specified width?
Answer:
x = 1 2 3
print (“original number: “, x)
print (“formatted number(right padding, width 6): “+” {: * < 7 d}”.format(x));
Output:
original number : 1 2 3
formatted number (right padding, width 6): 1 2 3 ***

Samacheer Kalvi 12th Computer Science Solutions Chapter 8 Strings and String Manipulations

Question 5.
Write a program to create a mirror of the given string. For example, “wel” = “lew“?
Answer:
str1 = input (“Enter a string: “)
str2 = ‘ ‘
index= -1
for i in str1:
str2 += str1 [index]
index -= 1
print (“The given string = { } \n The Reversed string = { }”.format(str 1, str 2))
Output:
Enter a string: welcome
The given string = welcome
The Reversed string = emoclew

Samacheer Kalvi 12th Computer Science Solutions Chapter 8 Strings and String Manipulations

Question 6.
Write a program to removes all the occurrences of a given character in a string?
Answer:
def removechar(s,c):
# find total no of occurrence of a character
counts = s.count(c)
# convert into list of characters
s = list(s)
# keep looping until counts become 0
while counts:
# remove char, from list
s.remove(c)
counts -= 1
# join remaining characters s = ” .join(s)
print(s)
s = “python programming”‘
remove char(s, ‘p’)
Output:
ython rogramming

Question 7.
Write a program to append a string to another string without using + = operator?
Answer:
s1 = input (“Enter the first string: “)
s2 = input (“Enter the second string: “)
print (‘concatenated strings =’,” ” ,join ([s1, s2]))
Output:
Enter the first string: Tamil
Enter the second string: Nadu
concatenated strings = Tamil Nadu

Samacheer Kalvi 12th Computer Science Solutions Chapter 8 Strings and String Manipulations

Question 8.
Write a program to swap two strings?
Answer:
print (“Enter Y for exit.”)
string1 = input(“Enter first string: “)
if string1 = = ‘x’:
exit();
else:
string2 = input (“Enter second string : “)
print (” \n Both strings before swap : “)
print (“First string = “, string1)
print (” Second string = “, string2)
temp = string1
string1 = string2
string2 = temp
print (“\n Both strings after swap: “)
print (“First string = “, string1)
print (” Second string = “, string2)
Output:
Enter ‘x’ for exit
Enter first string: code
Enter second string: python
Both strings before swap:
First string = code
Second string = python
Both strings after swap:
First string = python
Second string = code

Samacheer Kalvi 12th Computer Science Solutions Chapter 8 Strings and String Manipulations

Question 9.
Write a program to replace a string with another string without using replace ( )?
Answer:
s1 = input (“Enter the string to be replaced: “)
s2 = input (“Enter the string to replace with “)
s1 = s2
print (“Replaced string is “, s1)
Output:
Enter the string to be replaced: Computer
Enter the string to replace with: repcomputer
Replaced string is repcomputer

Samacheer Kalvi 12th Computer Science Solutions Chapter 8 Strings and String Manipulations

Question 10.
Write a program to count the number of characters, words and lines in a given string?
Answer:
string = input (“Enter string:”)
char = 0
word = 0
line = 0
for i in string:
char = char + 1
if (i = = “):
word = word + 1
elif (i = = ‘ \n’):
line = line +1
print (“Number of words in the string: “)
print (word)
print (“Number of characters in the string: “)
print (char)
print (“Number of lines in the string: “)
print (line)
Output:
Enter string: welcome to learning python
Number of words in the string : 4
Number of characters in the string : 26
Number of lines in the string : 1

Samacheer kalvi 12th Computer Science Strings and String Manipulations Additional Questions and Answers

PART – 1
I. Choose The Correct Answer

Question 1.
Strings in python can be created using ………………………….. quotes
(a) Single
(b) Double
(c) Triple
(d) All the above
Answer:
(d) All the above

Question 2.
Strings which contains double quotes should be defined with …………………….. quotes
(a) Single
(b) Double
(c) Triple
(d) All the these
Answer:
(c) Triple

Samacheer Kalvi 12th Computer Science Solutions Chapter 8 Strings and String Manipulations

Question 3.
The positive subscript of the string starts from ………………………….. and ends with …………………………
Answer:
0, n – 1

Question 4.
In strings, the negative index assigned from the last character to the first character in reverse order begins with …………………………
(a) 0
(b) 1
(c) -1
(d) -2
Answer:
(c) -1

Question 5.
How will you modify the string?
(a) A new string value can be assigned to the existing string variable
(b) Updating the string character by character
Answer:
(a) A new string value can be assigned to the existing string variable

Samacheer Kalvi 12th Computer Science Solutions Chapter 8 Strings and String Manipulations

Question 6.
Which function is used to change all occurrences of a particular character in a string?
(a) Replace ( )
(b) Change ( )
(c) Edit ( )
(d) Append ( )
Answer:
(a) Replace ( )

Question 7.
Which command is used to remove the entire string variable?
(a) Remove
(b) Del
(c) Delete
(d) Strike
Answer:
(b) Del

Question 8.
Joining of two or more strings is called as …………………………..
(a) Append
(b) Repeating
(c) Concatenation
(d) Strike
Answer:
(c) Concatenation

Samacheer Kalvi 12th Computer Science Solutions Chapter 8 Strings and String Manipulations

Question 9.
Adding more strings at the end of an existing strings is ………………………….
(a) Append
(b) Concatenation
(c) Repeating
(d) Slicing
Answer:
(a) Append

Question 10.
Find the wrongly matched pair from the following.
(a) Append ⇒ + =
(b) Concate ⇒ +
(c) Repeat ⇒ /
(d) Slice ⇒ [ ]
Answer:
(c) Repeat ⇒ /

Question 11.
Which operator is used to append a new string with an existing string?
(a) +
(b) + =
(c) *
(d) * =
Answer:
(b) + =

Samacheer Kalvi 12th Computer Science Solutions Chapter 8 Strings and String Manipulations

Question 12.
The multiplication operator is also called as ………………………….
(a) Append
(b) Concatenate
(c) Repeat
(d) Slice
Answer:
(c) Repeat

Question 13.
Which is used to display a string multiple number of times?
(a) Repeating
(b) *
(c) Multiplication operator
(d) All the above
Answer:
(d) All the above

Question 14.
…………………………. is a substring of a main string.
Answer:
Slice

Samacheer Kalvi 12th Computer Science Solutions Chapter 8 Strings and String Manipulations

Question 15.
In python, end value is considered as ……………………….
(a) 0
(b) n
(c) n – 1
(d) 1
Answer:
(c) n – 1

Question 16.
Find the wrong statement from the following.
(I) Slice a single character from a string
(II) Slice a substring
(III) Slice a substring without specifying beginning index
(IV) Slice a substring without specifying end index

(a) (I), (II)
(b) (II), (III), (IV)
(c) All are wrong
(d) All are correct
Answer:
(d) All are correct

Samacheer Kalvi 12th Computer Science Solutions Chapter 8 Strings and String Manipulations

Question 17.
The default value of stride is …………………………
(a) 0
(b) 1
(c) n
(d) n – 1
Answer:
(b) 1

Question 18.
If the stride is negative, then it will prints
(a) Third character
(b) Third word
(c) Full string
(d) Reverse order
Answer:
(d) Reverse order

Samacheer Kalvi 12th Computer Science Solutions Chapter 8 Strings and String Manipulations

Question 19.
…………………………. is the formatting character for signed decimal integer.
(a) %d or %i
(b) %d and %i
(c) %d %u
(d) %i &u
Answer:
(a) %d or %i

Question 20.
…………………….. is the formatting character for short numbers in floating point or exponential notation.
Answer:
% g or % G

Question 21.
Escape sequences starts with a ………………………..
Answer:
Back Slash

Question 22.
Find the wrong match
(a) Backslash – \b
(b) Backslash – //
(c) Carriage return – \r
(d) Line feed – \n
Answer:
(b) Backslash – //

Samacheer Kalvi 12th Computer Science Solutions Chapter 8 Strings and String Manipulations

Question 23.
Which function returns the length of the string?
(a) str len( )
(b) len(str)
(c) length( )
(d) strlength( )
Answer:
(b) len(str)

Question 24.
The function isalnum( ) returns ………………………. when it contains special characters.
Answer:
False

Samacheer Kalvi 12th Computer Science Solutions Chapter 8 Strings and String Manipulations

Question 25.
How many membership operators are there?
(a) 2
(b) 3
(c) 4
(d) 5
Answer:
(a) 2

Question 26.
……………………. is the membership operator.
(a) is
(b) at
(c) to
(d) in
Answer:
(d) in

Samacheer Kalvi 12th Computer Science Solutions Chapter 8 Strings and String Manipulations

Question 27.
……………………. function is a powerful function used for formatting strings.
Answer:
Format ( )

Question 28.
The ……………………. and ………………………. operators can be used with strings to determine whether a string is present another string.
Answer:
In, Not in

PART – II
II. Answer The Following Questions

Question 1.
Fill the Table with appropriate values.
Answer:
Samacheer Kalvi 12th Computer Science Solutions Chapter 8 Strings and String Manipulations

Samacheer Kalvi 12th Computer Science Solutions Chapter 8 Strings and String Manipulations

Question 2.
Find the output?
Answer:
Program
str1 = ‘ * ‘
i=1
while i<=5: print (str1*i)
i+=1
Output
*
* *
* * *
* * * *
* * * * *

PART – III
III. Answer The Following Question

Question 1.
Write note on replace function?
Answer:
The replace function replaces all occurrences of char 1 with char 2.
Example
>>> str1 =”How are you”
>>> print (str1)
How are you
>>>print (str1.replace(“o”, “e”))
Hew are yeu

Samacheer Kalvi 12th Computer Science Solutions Chapter 8 Strings and String Manipulations

Question 2.
Write note on Append Operator?
Answer:
Append (+ =)
Adding more strings at the end of an existing string is known as append. The operator + = is used to append a new string with an existing string.
Example:
>>> str1=’Welcome to ”
>>> str1+=”Leam Python”
>>> print (str1)
Welcome to Learn Python

Samacheer Kalvi 12th Computer Science Solutions Chapter 8 Strings and String Manipulations

Question 3.
Give any 6 formatting characters with their usage?
Formatting characters
Answer:
Samacheer Kalvi 12th Computer Science Solutions Chapter 8 Strings and String Manipulations

Samacheer Kalvi 12th Computer Science Solutions Chapter 8 Strings and String Manipulations

Question 4.
Write any 6 escape sequences with their description?
Answer:
Samacheer Kalvi 12th Computer Science Solutions Chapter 8 Strings and String Manipulations

PART – IV
IV. Answer The Following Questions

Question 1.
Explain any 10 Built-in string functions?
Answer:
Built – in String functions
Python supports the following built – in functions to manipulate string.
Samacheer Kalvi 12th Computer Science Solutions Chapter 8 Strings and String Manipulations

Samacheer Kalvi 12th Computer Science Solutions Chapter 2 Data Abstraction

Students can Download Computer Science Chapter 2 Data Abstraction Questions and Answers, Notes Pdf, Samacheer Kalvi 12th Computer Science Book Solutions Guide Pdf helps you to revise the complete Tamilnadu State Board New Syllabus and score more marks in your examinations.

Tamilnadu Samacheer Kalvi 12th Computer Science Solutions Chapter 2 Data Abstraction

Samacheer Kalvi 12th Computer Science Data Abstraction Text Book Back Questions and Answers

PART – I
I. Choose The Best Answer

Question 1.
Which of the following functions that build the abstract data type?
(a) Constructors
(b) Destructors
(c) Recursive
(d) Nested
Answer:
(a) Constructors

Question 2.
Which of the following functions that retrieve information from the data type?
(a) Constructors
(b) Selectors
(c) Recursive
(d) Nested
Answer:
(b) Selectors

Samacheer Kalvi 12th Computer Science Solutions Chapter 2 Data Abstraction

Question 3.
The data structure which is a mutable ordered sequence of elements is called ………………………
(a) Built in
(b) List
(c) Tuple
(d) Derived data
Answer:
(b) List

Question 4.
A sequence of immutable objects is called ………………………
(a) Built in
(b) List
(c) Tuple
(d) Derived data
Answer:
(c) Tuple

Question 5.
The data type whose representation is known are called ………………………
(a) Built in data type
(b) Derived data type
(c) Concrete data type
(d) Abstract data type
Answer:
(c) Concrete data type

Samacheer Kalvi 12th Computer Science Solutions Chapter 2 Data Abstraction

Question 6.
The data type whose representation is unknown are called ………………………
(a) Built in data type
(b) Derived data type
(c) Concrete data type
(d) Abstract datatype
Answer:
(d) Abstract datatype

Question 7.
Which of the following is a compound structure?
(a) Pair
(b) Triplet
(c) Single
(d) Quadrat
Answer:
(a) Pair

Samacheer Kalvi 12th Computer Science Solutions Chapter 2 Data Abstraction

Question 8.
Bundling two values together into one can be considered as ………………………
(a) Pair
(b) Triplet
(c) Single
(d) Quadrant
Answer:
(a) Pair

Question 9.
Which of the following allow to name the various parts of a multi – item object?
(a) Tuples
(b) Lists
(c) Classes
(d) quadrats
Answer:
(c) Classes

Samacheer Kalvi 12th Computer Science Solutions Chapter 2 Data Abstraction

Question 10.
Which of the following is constructed by placing expressions within square brackets?
(a) Tuples
(b) Lists
(c) Classes
(d) Quadrats
Answer:
(b) Lists

PART – II
II. Answer The Following Questions

Question 1.
What is abstract data type?
Answer:
Abstract Data type (ADT) is a type (or class) for objects whose behavior is defined by a set of value and a set of operations. The definition of ADT only mentions what operations are to be performed but not how these operations will be implemented.

Samacheer Kalvi 12th Computer Science Solutions Chapter 2 Data Abstraction

Question 2.
Differentiate constructors and selectors?
Answer:
Constructors are functions that build the abstract data type. Selectors are functions that retrieve information from the data type.
To create a city object, you’d use a function like
city = makecity (name, lat, Ion)
To extract the information of a city object, you would use functions like
getname (city)

Samacheer Kalvi 12th Computer Science Solutions Chapter 2 Data Abstraction

Question 3.
What is a Pair? Give an example?
Answer:
Pair is a compound structure which is made up of list or Tuple.
lst[(0, 10), (1, 20)] -where
Samacheer kalvi 12th Computer Science Solutions Chapter 2 Data Abstraction
Any way of bundling two values together into one can be considered as a pair. Lists are a common method to do so. Therefore List can be called as Pairs.

Question 4.
What is a List? Give an example?
Answer:
List is constructed by placing expressions within square brackets separated by commas. Example for List is [10, 20].

Samacheer Kalvi 12th Computer Science Solutions Chapter 2 Data Abstraction

Question 5.
What is a Tuple? Give an example?
Answer:
A tuple is a comma-separated sequence of values surrounded with parentheses. Tuple is similar to a list. The difference between the two is that you cannot change the elements of a tuple once it is assigned whereas in a list, elements can be changed.
Example colour = (‘red’, ‘blue’, ‘Green’)

PART – III
III. Answer The Following Questions

Question 1.
Differentiate Concrete data type and abstract datatype?
Answer:
Concrete data type:

  1. A concrete data type is a data type whose representation is known.
  2. Concrete data types or structures (CDT’s) are direct implementations of a relatively simple concept.

Abstract data type:

  1. Abstract data type the representation of a data type is unknown.
  2. Abstract Data Types (ADT’s) offer a high level view (and use) of a concept independent of its implementation.

Samacheer Kalvi 12th Computer Science Solutions Chapter 2 Data Abstraction

Question 2.
Which strategy is used for program designing? Define that Strategy?
Answer:
We are using here a powerful strategy for designing programs: ‘wishful thinking’.
Wishful Thinking is the formation of beliefs and making decisions according to what might be pleasing to imagine instead of by . appealing to reality.

Question 3.
Identify Which of the following are constructors and selectors?
Answer:
(a) N1 = number ( ) – constructors
(b) Accetnum (n1) – selectors
(c) Displaynum (n1) – selectors
(d) eval (a/b) – selectors
(e) x, y = makeslope(m), makeslope (n) – constructors
(f) display O – selectors

Samacheer Kalvi 12th Computer Science Solutions Chapter 2 Data Abstraction

Question 4.
What are the different ways to access the elements of a list. Give example?
Answer:
List is constructed by placing expressions within square brackets separated by commas. Example for List is [10, 20].
The elements of a list can be accessed in two ways. The first way is via our familiar method of multiple assignment, which unpacks a list into its elements and binds each element to a different name.
1st: = [10, 20]
x, y: = 1st
In the above example x will become 10 and y will become 20.
A second method for accessing the elements in a list is by the element selection operator, also expressed using square brackets. Unlike a list literal, a square – brackets expression directly following another expression does not evaluate to a list value, but instead selects an element from the value of the preceding expression.
1st [0]
10
1st [1]
20

Samacheer Kalvi 12th Computer Science Solutions Chapter 2 Data Abstraction

Question 5.
Identify Which of the following are List, Tuple and class?
(a) arr [1, 2, 34]
(b) arr (1, 2, 34)
(c) student [rno, name, mark]
(d) day = (‘sun’, ‘mon’, ‘tue’, ‘wed’)
(e) x= [2, 5, 6.5, [5,6], 8.2]
(f) employee [eno, ename, esal, eaddress]
Answer:
List: (a) arr [1, 2, 34]
(e) x= [2, 5, 6.5, [5,6], 8.2]
Tuple: (b) arr (1, 2, 34)
(d) day = (‘sun’, ‘mon’, ‘tue’, ‘wed’)
Class: (c) student [mo, name, mark]
(f) employee [eno, ename, esal, eaddress]

PART – IV
IV. Answer The Following Questions

Question 1.
How will you facilitate data abstraction. Explain it with suitable example?
Answer:
The definition of ADT only mentions what operations are to be performed but not how these operations will be implemented. It does not specify how data will be organized in memory and what algorithms will be used for implementing the operations. It is called “abstract” because it gives an implementation independent view. The process of providing only the essentials and hiding the details is known as abstraction.
To facilitate data abstraction, you will need to create two types of functions.

constructors and selectors:
Constructors are functions that build the abstract data type. Selectors are functions that retrieve information from the data type.
To create a city object, you’d use a function like city = makecity (name, lat, Ion)
To extract the information of a city object, you would use functions like

  1. getname(city)
  2. getlat(city)
  3. getlon(city)

In the above pseudo code the function which creates the object of the city is the constructor, city = makecity (name, lat, Ion)
Here makecity (name, lat, Ion) is the constructor which creates the object city.
Samacheer Kalvi 12th Computer Science Solutions Chapter 2 Data Abstraction
Selectors are nothing but the functions that retrieve information from the data type. Therefore in the above code

  1. getname(city)
  2. getlat(city)
  3. getlon(city)

are the selectors because these functions extract the information of the city object.
Samacheer Kalvi 12th Computer Science Solutions Chapter 2 Data Abstraction
Data abstraction is supported by defining an abstract data type (ADT), which is a collection of constructors and selectors. Constructors create an object, bundling together different pieces of information, while selectors extract individual pieces of information from the object.

Samacheer Kalvi 12th Computer Science Solutions Chapter 2 Data Abstraction

Question 2.
What is a List? Why List can be called as Pairs. Explain with suitable example?
Answer:
List is constructed by placing expressions within square brackets separated by commas. Example for List is [10, 20],
The elements of a list can be accessed in two ways. The first way is via our familiar method of multiple assignment, which unpacks a list into its elements and binds each element to a different name.
1st: = [10, 20]
x, y: = 1st
In the above example x will become 10 and y will become 20.
A second method for accessing the elements in a list is by the element selection operator, also expressed using square brackets. Unlike a list literal, a square – brackets expression directly following another expression does not evaluate to a list value, but instead selects an element from the value of the preceding expression.
1st [0]
10
1st [1]
20
In both the example mentioned above mathematically we can represent list similar to a set.
1st [(0, 10), (1, 20)] – where
Samacheer Kalvi 12th Computer Science Solutions Chapter 2 Data Abstraction
Any way of bundling two values together into one can be considered as a pair. Lists are a common method to do so. Therefore List can be called as Pairs.

Samacheer Kalvi 12th Computer Science Solutions Chapter 2 Data Abstraction

Question 3.
How will you access the multi – item. Explain with example?
Answer:
List allow data abstraction in that you can give a name to a set of memory cells. For instance, in the game Mastermind, you must keep track of a list of four colors that the player guesses. Instead of using four separate variables (color 1, color2, color3, and color4) you can use a single variable ‘Predict’, e.g.,
Predict = [‘red’, ‘blue’, ‘green’, ’green’]
What lists do not allow us to do is name the various parts of a multi- item object. In the case of a Predict, you don’t really need to name the parts:
using an index to get to each color suffices.
But in the case of something more complex, like a person, we have a multi – item object where each ‘item’ is a named thing: the firstName, the last Name, the id, and the email. One could use a list to represent a person.
Samacheer Kalvi 12th Computer Science Solutions Chapter 2 Data Abstraction
Person = [‘Padmashri’, ‘Baskar’, ‘994 – 222 – 1234’, ‘[email protected]’]
but such a representation doesn’t explicitly specify what each part represents.
For this problem instead of using a list, you can use the structure constmct (In OOP languages it’s called class construct) to represent multi-part objects where each part is named (given a name). Consider the following pseudo code:
class Person:
creation( )
firstName: = “”
lastName: = ” ”
id: = ” ”
email : = “”
The new data type Person is pictorially represented as
Samacheer Kalvi 12th Computer Science Solutions Chapter 2 Data Abstraction
The class (structure) constmct defines the form for multi – part objects that represent a person. Its defintion adds a new data type, in this case a type named Person. Once defined, we can create new variables (instances) of the type. In this example Person is referred to as a class or a type, while p1 is referred to as an object or an instance. You can think of class Person as a cookie cutter, and p1 as a particular cookie. Using the cookie cutter you can make many cookies. Same way using class you can create many objects of that type.

Samacheer kalvi 12th Computer Science Data Abstraction Additional Questions and Answers

PART – 1
I. Choose The Best Answer

Question 1.
How many types of functions are needed to facilitate abstraction?
(a) 1
(b) 2
(c) 3
(d) 4
Answer:
(b) 2

Samacheer Kalvi 12th Computer Science Solutions Chapter 2 Data Abstraction

Question 2.
ADT stands for …………………………..
(a) Advanced Data Typing
(b) Application Developing Tool
(c) Abstract data types
(d) Advanced data types
Answer:
(c) Abstract data types

Question 3.
The Splitting of program into many modules are called as ……………………………
(a) Modularity
(b) Structures
(c) Classes
(d) List
Answer:
(a) Modularity

Samacheer Kalvi 12th Computer Science Solutions Chapter 2 Data Abstraction

Question 4.
……………………………. are the representation for ADT.
(a) List
(b) Classes
(c) Int
(d) Float
Answer:
(b) Classes

Question 5.
Linked list are of …………………………..
(a) Single
(b) Double
(c) Multiple
(d) Both a and b
Answer:
(d) Both a and b

Samacheer Kalvi 12th Computer Science Solutions Chapter 2 Data Abstraction

Question 6.
The process of providing only the essentials and hiding the details is known as …………………………..
(a) Modularity
(b) Structure
(c) Tuple
(d) Abstraction
Answer:
(d) Abstraction

Question 7.
Identify the constructor from the following
(a) City = makecity(name, lat, lon)
(b) getname(city)
(c) getlat(city)
(d) getlon(city)
Answer:
(a) City = makecity(name, lat, lon)

Samacheer Kalvi 12th Computer Science Solutions Chapter 2 Data Abstraction

Question 8.
: = is called as …………………………..
(a) Assigned as
(b) Becomes
(c) Both a and b
(d) None of these
Answer:
(c) Both a and b

Question 9.
In list 1st [(0, 10), (1, 20)] – 0 and 1 represents …………………………..
(a) Value
(b) Index
(c) List identifier
(d) Tuple
Answer:
(b) Index

Samacheer Kalvi 12th Computer Science Solutions Chapter 2 Data Abstraction

Question 10.
How many ways of representing pair data type are there?
(a) 1
(b) 2
(c) 3
(d) 4
Answer:
(b) 2

Question 11.
nums [1] represent that you are accessing ………………………….. element.
(a) 0
(b) 1
(c) 2
(d) 3
Answer:
(b) 1

Samacheer Kalvi 12th Computer Science Solutions Chapter 2 Data Abstraction

Question 12.
nums [1] indicate that we are accessing ………………………….. element.
(a) 0
(b) 1
(c) 2
(d) many
Answer:
(c) 2

Question 13.
How many objects can be created from a class?
(a) 0
(b) 1
(c) 2
(d) many
Answer:
(d) many

PART – II
II. Answer The Following Questions

Question 1.
What are the two parts of a program?
Answer:
The two parts of a program are, the part that operates on abstract data and the part that defines a concrete representation.

Samacheer Kalvi 12th Computer Science Solutions Chapter 2 Data Abstraction

Question 2.
Give the pseudo code to represent a rational number as a pair of two integers?
Answer:
You can now represent a rational number as a pair of two integers in pseudo code: a numerator and a denominator.
rational (n, d):
return [n, d]
numer (x):
return x [0]
denom (x):
return x [1]

Question 3.
What are the two ways of representing the pair data type?
Answer:
Two ways of representing the pair data type. The first way is using List construct and the second way to implement pairs is with the tuple construct.

Samacheer Kalvi 12th Computer Science Solutions Chapter 2 Data Abstraction

Question 4.
Differentiate tuple and list?
List:
In List square bracket is used.

Tuple:
In Tuple parenthesis is used.

Question 5.
Give an example for representation of Tuple as a pair?
Answer:
Representation of Tuple as a Pair
nums : = (1, 2)
nums [0]
1
nums [1]
2

Samacheer Kalvi 12th Computer Science Solutions Chapter 2 Data Abstraction

Question 6.
Define class?
Answer:
A class as bundled data and the functions that work on that data.

PART – III
III. Answer The Following Questions

Question 1.
Give the pseudo code to compute the distance between two city objects?
Answer:
The following pseudo code will compute the distance between two city objects:
distance(city 1, city2):
1t1, 1g1: = getlat (city1), getlon (city1)
1t2, 1g2: = getlat (city2), getlon (city2)
return ((1t1 – 1t2) ** 2 + (1g1 – 1g2) ** 2)1/2

Samacheer Kalvi 12th Computer Science Solutions Chapter 1 Function

Students can Download Computer Science Chapter 1 Function Questions and Answers, Notes Pdf, Samacheer Kalvi 12th Computer Science Book Solutions Guide Pdf helps you to revise the complete Tamilnadu State Board New Syllabus and score more marks in your examinations.

Tamilnadu Samacheer Kalvi 12th Computer Science Solutions Chapter 1 Function

Samacheer Kalvi 12th Computer Science Function Text Book Back Questions and Answers

PART – 1
I. Choose The Best Answer

Question 1.
The small sections of code that are used to perform a particular task is called ……………………….
(a) Subroutines
(b) Files
(c) Pseudo code
(d) Modules
Answer:
(a) Subroutines

Samacheer Kalvi 12th Computer Science Solutions Chapter 1 Function

Question 2.
Which of the following is a unit of code that is often defined within a greater code structure?
(a) Subroutines
(b) Function
(c) Files
(d) Modules
Answer:
(b) Function

Question 3.
Which of the following is a distinct syntactic block?
(a) Subroutines
(b) Function
(c) Definition
(d) Modules
Answer:
(c) Definition

Samacheer Kalvi 12th Computer Science Solutions Chapter 1 Function

Question 4.
The variables in a function definition are called as ……………………….
(a) Subroutines
(b) Function
(c) Definition
(d) Parameters
Answer:
(d) Parameters

Question 5.
The values which are passed to a function definition are called ……………………….
(a) Arguments
(b) Subroutines
(c) Function
(d) Definition
Answer:
(a) Arguments

Samacheer Kalvi 12th Computer Science Solutions Chapter 1 Function

Question 6.
Which of the following are mandatory to write the type annotations in the function definition?
(a) Curly braces
(b) Parentheses
(c) Square brackets
(d) Indentations
Answer:
(b) Parentheses

Question 7.
Which of the following defines what an object can do?
(a) Operating System
(b) Compiler
(c) Interface
(d) Interpreter
Answer:
(c) Interface

Samacheer Kalvi 12th Computer Science Solutions Chapter 1 Function

Question 8.
Which of the following carries out the instructions defined in the interface?
(a) Operating System
(b) Compiler
(c) Implementation
(d) Interpreter
Answer:
(c) Implementation

Question 9.
The functions which will give exact result when same arguments are passed are called ……………………….
(a) Impure functions
(b) Partial Functions
(c) Dynamic Functions
(d) Pure functions
Answer:
(d) Pure functions

Samacheer Kalvi 12th Computer Science Solutions Chapter 1 Function

Question 10.
The functions which cause side effects to the arguments passed are called ……………………….
(a) Impure functions
(b) Partial Functions
(c) Dynamic Functions
(d) Pure functions
Answer:
(a) Impure functions

PART – II
II. Answer The Following Questions

Question 1.
What is a subroutine?
Answer:
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.

Question 2.
Define Function with respect to Programming language?
Answer:
A function is a unit of code that is often defined within a greater code structure. Specifically, a function contains a set of code that works on many kinds of inputs, like variants, expressions and produces a concrete output.

Samacheer Kalvi 12th Computer Science Solutions Chapter 1 Function

Question 3.
Write the inference you get from X: = (78)?
Answer:
Value 78 being bound to the name X.

Question 4.
Differentiate interface and implementation?
Answer:
Interface:
Interface just defines what an object can do, but won’t actually do it.

Implementation:
Implementation carries out the instructions defined in the interface.

Samacheer Kalvi 12th Computer Science Solutions Chapter 1 Function

Question 5.
Which of the following is a normal function definition and which is recursive function definition?
Answer:
(I) Let Recursive sum x y:
return x + y

(II) let disp:
print ‘welcome’

(III) let Recursive sum num:
if (num! = 0) then return num + sum (num – 1) else
return num

  1. Recursive function
  2. Normal function
  3. Recursive function

PART – III
III. Answer The Following Questions

Question 1.
Mention the characteristics of Interface?
Answer:
Characteristics of interface:

  1. The class template specifies the interfaces to enable an object to be created and operated properly.
  2. An object’s attributes and behaviour is controlled by sending functions to the object.

Samacheer Kalvi 12th Computer Science Solutions Chapter 1 Function

Question 2.
Why strlen is called pure function?
Answer:
strlen (s) is called each time and strlen needs to iterate over the whole of ‘s’. If the compiler is smart enough to work out that strlen is a pure function and that ‘s’ is not updated in the lbop, then it can remove the redundant extra calls to strlen and make the loop to execute only one time. This function reads external memory but does not change it, and the value returned derives from the external memory accessed.

Question 3.
What is the side effect of impure function. Give example?
Answer:
Impure Function:

  • The return value of the impure functions does not solely depend on its arguments passed. Hence, if you call the impure functions with the same set of arguments, you might get the different return values. For example, random( ), Date( ).
  • They may modify the arguments which are passed to them.

Samacheer Kalvi 12th Computer Science Solutions Chapter 1 Function

Question 4.
Differentiate pure and impure function?
Answer:
Pure Function:

  1. The return value of the pure functions solely depends on its arguments passed.
  2. If you call the pure functions with the same set of arguments, you will always get the same return values.
  3. They do not have any side effects.
  4. They do not modify the arguments which are passed to them.

Impure Function:

  1. The return value of the impure functions does not solely depend on its arguments passed.
  2. If you call the impure functions with the same set of arguments, you might get the different return values. For example, random( ), Date( ).
  3. They have side effects.
  4. They may modify the arguments which are passed to them.

Samacheer Kalvi 12th Computer Science Solutions Chapter 1 Function

Question 5.
What happens if you modify a variable outside the function? Give an example?
Answer:
When a function depends on variables or functions outside of its definition block, you can never be sure that the function will behave the same every time it’s called.
For example let y: = 0
(int) inc (int) x
y: = y + x;
return (y)
In the above example the value of y get changed inside the function defintion due to which the result will change each time. The side effect of the inc ( ) function is it is changing the data ‘ of the external visible variable ‘y’.

PART – IV
IV. Answer The Following Questions

Question 1.
What are called Parameters and write a note on?
Answer:

  1. Parameter without Type
  2. Parameter with Type Parameters (and arguments)

Parameters are the variables in a function definition and arguments are the values which are passed to a function definition.

(I) Parameter without Type
Let us see an example of a function definition:
(requires: b> = 0)
(returns: a to the power of b)
let rec pow a b: =
if b = 0 then 1
else a * pow a (b – 1)
In the above function definition variable ‘b’ is the parameter and the value which is passed to the variable ‘b’ is the argument. The precondition (requires) and postcondition (returns) of the function is given. Note we have not mentioned any types: (data types). Some language compiler solves this type (data type) inference problem algorithmically, but some require the type to be mentioned.

In the above function definition if expression can return 1 in the then branch, by the typing rule the entire if expression has type int. Since the if expression has type ‘int ’, the function’s return type also be ‘inf. ‘b ’is compared to 0 with the equality operator, so ‘b ’is also a type of ‘int. Since a is multiplied with another expression using the * operator, ‘a’ must be an int.

(II) Parameter with Type
Now let us write the same function definition with types for some reason:
(requires: b > 0)
(returns: a to the power of b)
let rec pow (a: int) (b: int): int : =
if b = 0 then 1
else a * pow b (a – 1)
When we write the type annotations for ‘a ’ and ‘b ’ the parentheses are mandatory. Generally we can leave out these annotations, because it’s simpler to let the compiler infer them. There are times we may want to explicitly write down types. This is useful on times when you get a type error from the compiler that doesn’t make sense. Explicitly annotating the types can help with debugging such an error message.

The syntax to define functions is close to the mathematical usage: the definition is introduced by the keyword let, followed by the name of the function and its arguments; then the formula that computes the image of the argument is written after an = sign. If you want to define a recursive function: use “let rec ” instead of “let
Syntax: The syntax for function definitions:

let rec fnal a2 … an : = k
Here the fn is a variable indicating an identifier being used as a function name. The names ‘al ’ to ‘an ’ are variables indicating the identifiers used as parameters. The keyword ‘rec ’ is required if fn ’ is to be a recursive function; otherwise it may be omitted.
For example: let us see an example to check whether the entered number is even or odd.
(requires: x> = 0)
let rec even x : = x = 0 || odd (x – 1)
return ‘even’
(requires: x> = 0)
let odd x : =
x< >0 && even (x – 1)
return ‘odd’
The syntax for function types:
x → y
x1 → x2 → y
x1 → … → xn → y
The ‘x’ and ‘y’ are variables indicating types. The type x → y is the type of a function that gets an input of type ‘x’ and returns an output of type ‘y’. Whereas x1 → x2 → y is a type of a function that takes two inputs, the first input is of type ‘x1 ’ and the second input of type ‘x2’, and returns an output of type ‘y’. Likewise x1 → … → xn → y has type ‘x’ as input of n arguments and ‘y’ type as output.

Samacheer Kalvi 12th Computer Science Solutions Chapter 1 Function

Question 2.
Identify in the following program
Answer:
let rec gcd a b : =
if b < > 0 then gcd b (a mod b) else return a
(I) Name of the function
gcd

(II) Identify the statement which tells it is a recursive function
let rec

(III) Name of the argument variable
a, b

(IV) Statement which invoke the function recursively
gcd b(a mod b) [when b < > 0]

(V) Statement which terminates the recursion
return a (when b becomes 0).

Samacheer Kalvi 12th Computer Science Solutions Chapter 1 Function

Question 3.
Explain with example Pure and impure functions?
Answer:
Pure functions:
Pure functions are functions which will give exact result when the same arguments are passed. For example the mathematical function sin (0) always results 0. This means that every time you call the function with the same arguments, you will always get the same result. A function can be a pure function provided it should not have any external variable which will alter the behaviour of that variable.
Let us see an example
let square x
return: x * x
The above function square is a pure function because it will not give different results for same input. There are various theoretical advantages of having pure functions. One advantage is that if a function is pure, then if it is called several times with the same arguments, the compiler only needs to actually call the function once. Let’s see an example let i: = 0;
if i < strlen (s) then – Do something which doesn’t affect s ++ i If it is compiled, strlen (s) is called each time and strlen needs to iterate over the whole of ‘s’.

If the compiler is smart enough to work out that strlen is a pure function and that ‘s’ is not updated in the loop, then it can remove the redundant extra calls to strlen and make the #loop to execute only one time. From these what we can understand, strlen is a pure function because the function takes one variable as a parameter, and accesses it to find its length.

This function reads external memory but does not change it, and the value returned derives from the external memory accessed. Impure functions: The variables used inside the function may cause side effects through the functions which are not passed with any arguments.

In such cases the function is called impure function. When a function depends on variables or functions outside of its definition block, you can never be sure that the function will behave the same every time it’s called. For example the mathematical function random Q will give different outputs for the same function call, let Random number let a : = random( ) if a > 10 then
return: a
else
return: 10
Flere the function Random is impure as it is not sure what will be the result when we call the function.

Samacheer Kalvi 12th Computer Science Solutions Chapter 1 Function

Question 4.
Explain with an example interface and implementation?
Answer:
Interface Vs Implementation:
An interface is a set of action that an object can do. For example when you press a light switch, the light goes on, you may not have cared how it splashed the light. In Object Oriented Programming language, an Interface is a description of all functions that a class must have in order to be a new interface.

In our example, anything that “ACTSLIKE” a light, should have function defnitions like turn on ( ) and a turn off ( ). The purpose of interfaces is to allow the computer to enforce the properties of the class of TYPE T (whatever the interface is) must have functions called X, Y, Z, etc.

A class declaration combines the external interface (its local state) with an implementation of that interface (the code that carries out the behaviour). An object is an instance created from the class. The interface defines an object’s visibility to the outside world.

The difference between interface and implementation is:

Interface:
Interface just defines what an object can do, but won’t actually do it. Implementation carries out the instructions defined in the interface.

Implementation:
Implementation carries out the instructions defined in the interface.
In object oriented programs classes are the interface and how the object is processed and executed is the implementation.

Characteristics of interface

  1. The class template specifies the interfaces to enable an object to be created and operated properly.
  2. An object’s attributes and behaviour is controlled by sending functions to the object.

For example, let’s take the example of increasing a car’s speed.
Samacheer kalvi 12th Computer Science Solutions Chapter 1 Function
The person who drives the car doesn’t care about the internal working. To increase the speed of the car he just presses the accelerator to get the desired behaviour. Here the accelerator is the interface between the driver (the calling / invoking object) and the engine (the called object). In this case, the function call would be Speed (70): This is the interface.

Internally, the engine of the car is doing all the things. It’s where fuel, air, pressure, and electricity come together to create the power to move the vehicle. All of these actions are separated from the driver, who just wants to go faster.

Let us see a simple example, consider the following implementation of a function that finds the minimum of its three arguments:
let min 3 x y z : =
if x < y then
if x < z then x else z
else
if y < z then y else z

Practice Programs
Question 1.
Write algorithmic function definition to find the minimum among 3 numbers?
Answer:
let min 3 x y z : =
if x < y then
if x < z then x else z
else
if y < z then y else z

Samacheer Kalvi 12th Computer Science Solutions Chapter 1 Function

Question 2.
Write algorithmic recursive function definition to find the sum of n natural numbers?
Answer:
let rec sum num:
if (num! = 0) then return num + sum (num – 1)
else
return num

Samacheer kalvi 12th Computer Science Function Additional Questions and Answers

PART – 1
I. Choose The Best Answer

Question 1.
……………………… are expressed using statements of a programming language.
(a) Algorithm
(b) Procedure
(c) Specification
(d) Abstraction
Answer:
(a) Algorithm

Question 2.
……………………… are the basic building blocks of a computer programs.
(a) Code
(b) Subroutines
(c) Modules
(d) Variables
Answer:
(b) Subroutines

Samacheer Kalvi 12th Computer Science Solutions Chapter 1 Function

Question 3.
In programming languages, subroutines are called as …………………………..
(a) Functions
(b) Task
(c) Modules
(d) Code
Answer:
(a) Functions

Question 4.
Find the correct statement from the following.
(a) a : = (24) has an expression
(b) (24) is an expression
Answer:
(a) a : = (24) has an expression

Samacheer Kalvi 12th Computer Science Solutions Chapter 1 Function

Question 5.
……………………… binds values to names.
(a) Algorithms
(b) Variables
(c) Interface
(d) Definitions
Answer:
(d) Definitions

Question 6.
Identify the statement which is wrong.
(a) Definitions are expressions
(b) Definitions are distinct syntactic blocks.
(c) Definitions can have expressions, nested inside them.
Answer:
(a) Definitions are expressions

Question 7.
The name of the function in let rec pow ab : = is …………………………
(a) Let
(b) Rec
(c) Pow
(d) a b
Answer:
(c) Pow

Samacheer Kalvi 12th Computer Science Solutions Chapter 1 Function

Question 8.
In function definition pre condition is given by ……………………….
(a) Needed
(b) Let
(c) Returns
(d) Requires
Answer:
(d) Requires

Question 9.
In function definition post condition is given by …………………………
(a) Needed
(b) Let
(c) Returns
(d) Requires
Answer:
(c) Returns

Samacheer Kalvi 12th Computer Science Solutions Chapter 1 Function

Question 10.
In b = 0, = is ……………………….. operator
(a) Assignment
(b) Equality
(c) Logical
(d) Not equal
Answer:
(b) Equality

Question 11.
The formula should be written after ……………………….. sign
(a) +
(b) –
(c) =
(d) ++
Answer:
(c) =

Samacheer Kalvi 12th Computer Science Solutions Chapter 1 Function

Question 12.
To define a recursive function, …………………………. is used.
(a) Let
(b) Let r
(c) Let rfn
(d) Let rec
Answer:
(d) Let rec

Question 13.
Find which is false.
(a) All function definitions are static
(b) All function definitions are dynamic
Answer:
(b) All function definitions are dynamic

Question 14.
A ……………………….. combines the external interface with an implementation of that interface.
Answer:
class declaration

Question 15.
An …………………………. is an instance created from the class.
(a) Object
(b) Functions
(c) Subroutines
(d) Definitions
Answer:
(a) Object

Samacheer Kalvi 12th Computer Science Solutions Chapter 1 Function

Question 16.
Find the statement which is not true.
(a) The interface defines an objects visibility to the outside world
(b) Interface defines what an object can do.
(c) In object oriented programs, objects are interfaces
Answer:
(c) In object oriented programs, objects are interfaces

Question 17.
An ………………………… attributes and behaviour is controlled by sending functions to the object.
Answer:
Objects

Question 18.
The class template specifies the ………………………. to enable an object to be created and operated properly.
Answer:
Interfaces

Question 19.
The accelerator is the …………………………… between the driver and the engine.
(a) Interface
(b) Object
(c) Instruction
(d) Code
Answer:
(a) Interface

Samacheer Kalvi 12th Computer Science Solutions Chapter 1 Function

Question 20.
sin (0) = 0 is an example for ………………………. function.
(a) Impure
(b) Pure
(c) Interface
(d) Instruction
Answer:
(b) Pure

Question 21.
Find the impure function from the following.
(a) Sin (0)
(b) Square x
(c) Strlen (s)
(d) None of these
Answer:
(d) None of these

Question 22.
The function random ( ) is an example for …………………….. functions.
Answer:
Impure

Samacheer Kalvi 12th Computer Science Solutions Chapter 1 Function

Question 23.
Why is the function random( ) is a impure function?
(a) It gives different outputs for same function call
(b) It gives different outputs when 0 is given
(c) It will not give different output
Answer:
(a) It gives different outputs for same function call

Question 24.
Which function definition, doesn’t modify the arguments passed to them?
(a) Pure function
(b) Impure function
(c) Object
(d) Interface
Answer:
(a) Pure function

Samacheer Kalvi 12th Computer Science Solutions Chapter 1 Function

Question 25.
How many parameters are defined in the function let rec gcd a b : =
(a) 0
(b) 1
(c) 2
(d) 3
Answer:
(c) 2

Question 26.
In the function definition, the keyword let is followed by …………………………
(a) Function name
(b) Arguments
(c) Parameters
(d) Implementations
Answer:
(a) Function name

Question 27.
Find the correct statement from the following function definitions. let rec p on a b : =
(a) data type of the parameters are given
(b) data type of the parameters are not mentioned
Answer:
(b) data type of the parameters are not mentioned

Samacheer Kalvi 12th Computer Science Solutions Chapter 1 Function

Question 28.
If a function is not a recursive one, then ……………………………. is used
(a) abc
(b) gcd
(c) let
(d) let rec
Answer:
(c) let

Question 29.
Find the name of the function,
let rec even x : =
(a) Let
(b) Rec
(c) Even
(d) x
Answer:
(c) Even

Question 30.
Match the following function definitions with their terms.
let rec odd xy : =

  1. Keyword – (i) Xy
  2. Recursion – (ii) Odd
  3. Function name – (iii) Rec
  4. Parameters – (iv) let

(a) 1 – (iv) 2 – (iii) 3 – (ii) 4 – (i)
(b) 1 – (i) 2 – (ii) 3 – (iii) 4 – (iv)
(c) 1 – (iv) 2 – (i) 3 – (ii) 4 – (iii)
(d) 1 – (i) 2 – (iv) 3 – (ii) 4 – (iii)
Answer:
(a) 1 – (iv) 2 – (iii) 3 – (ii) 4 – (i)

Samacheer Kalvi 12th Computer Science Solutions Chapter 1 Function

Question 31.
In object oriented programming language, an is a description of all functions that a class must have
(a) Object
(b) Class
(c) Interface
(d) Code
Answer:
(c) Interface

Question 32.
The ……………………… defines an object’s visibility to the outside world.
(a) Object
(b) Interface
(c) Pure function
(d) Impure function
Answer:
(b) Interface

Samacheer Kalvi 12th Computer Science Solutions Chapter 1 Function

Question 33.
Find the correct statement.
(i) Evaluation of pure function causes side effects to its output.
(ii) Evaluation of Impure function causes side effects to its output.
Answer:
(ii) Evaluation of Impure function causes side effects to its output.

PART – II
II. Answer The Following Questions

Question 1.
What are the two types of parameter passing?
Answer:

  1. Parameter without type
  2. Parameter with type

Question 2.
In the function definition
let rec pow a b : = Is it recursive function. If so Explain. Why?
Answer:
Yes it is a recursive function. It is given in the function definition as rec which indicates recursive function.

Samacheer Kalvi 12th Computer Science Solutions Chapter 1 Function

Question 3.
Write the syntax for the function definitions?
Answer:
let rec fn a1 a2 … an : = k
fn : Function name
a1 … an – variable
rec: recursion

Question 4.
Define recursive functions: How will you define it?
Answer:
A function definition which calls itself is called recursive functions. It is given by let rec.

PART – III
III. Answer The Following Questions

Question 1.
Write note on Definitions?
Answer:
Definitions bind values to names, Definitions are not expressions, Definitions are distinct syntactic blocks. Definitions can have expressions nested inside them, and vice – versa.

Samacheer Kalvi 12th Computer Science Solutions Chapter 1 Function

Question 2.
Write the pre condition and post condition for the function?
Answer:
(requires: b > 0)
– (returns: a to the power of b) let rec pow(a : int) (b : int): int: =

  1. Pre condition : b > 0
  2. Post condition : a to the power of b.

Question 3.
Give function definition for the Chameleons of Chromeland problem?
Answer:
let rec monochromatize abc : =
if a > 0 then
a, b, c : = a – 1, b – 1, c + 2
else
a: = 0, b: = 0, c: = a + b + c
return c

Samacheer Kalvi 12th Computer Science Solutions Chapter 1 Function

Question 4.
Give the flow chart for Chameleons of Chromeland problem?
Answer:
The algorithm is depicted in the flowchart as below:
Samacheer Kalvi 12th Computer Science Solutions Chapter 1 Function

Samacheer Kalvi 12th Computer Science Solutions Chapter 1 Function

Question 5.
Give the example function definition for parameter with type?
Answer:
Parameter with Type:
Now let us write the same function definition with types for some reason:
(requires: b> 0)
(returns: a to the power of b ) let rec pow (a: int) (b: int): int : =
if b = 0 then 1
else a * pow b (a – 1)

Samacheer Kalvi 11th Maths Solutions Chapter 11 Integral Calculus Ex 11.13

You can Download Samacheer Kalvi 11th Maths Book Solutions Guide Pdf, Tamilnadu State Board help you to revise the complete Syllabus and score more marks in your examinations.

Tamilnadu Samacheer Kalvi 11th Maths Solutions Chapter 11 Integral Calculus Ex 11.13

Choose the correct or most suitable answer from given four alternatives.
Question 1.
If \(\int f(x) d x\) = g(x) + c, then \(\int f(x) g^{\prime}(x) d x\)
Samacheer Kalvi 11th Maths Solutions Chapter 11 Integral Calculus Ex 11.13 1
Solution:
(a)
Samacheer Kalvi 11th Maths Solutions Chapter 11 Integral Calculus Ex 11.13 2

Question 2.
If Samacheer Kalvi 11th Maths Solutions Chapter 11 Integral Calculus Ex 11.13 3, then the value of k is ……………
(a) log 3
(b) -log 3
(c) \(-\frac{1}{\log ^{3}}\)
(d) \(\frac{1}{\log 3}\)
Solution:
(c)
Samacheer Kalvi 11th Maths Solutions Chapter 11 Integral Calculus Ex 11.13 4

Question 3.
If \(\int f^{\prime}(x) e^{x^{3}} d x\) = (x – 1)ex2, then f(x) is …………………
Samacheer Kalvi 11th Maths Solutions Chapter 11 Integral Calculus Ex 11.13 5
Solution:
(d)
Samacheer Kalvi 11th Maths Solutions Chapter 11 Integral Calculus Ex 11.13 6

Question 4.
The gradient (slope) of a curve at any point (x, y) is \(\frac{x^{2}-4}{x^{2}}\). If the curve passes through the point(2, 7), then the equation of the curve is ………….
(a) y = x + \(\frac{4}{x}\) + 3
(b) y = x + \(\frac{4}{x}\) + 4
(c) y = x2 + 3x + 4
(d) y = x2 – 3x + 6
Solution:
Samacheer Kalvi 11th Maths Solutions Chapter 11 Integral Calculus Ex 11.13 7

Samacheer Kalvi 11th Maths Solutions Chapter 11 Integral Calculus Ex 11.13

Question 5.
Samacheer Kalvi 11th Maths Solutions Chapter 11 Integral Calculus Ex 11.13 8
(a) cot (xex) + c
(b) sec (xex) + c
(c) tan (xex) + c
(d) cos (xex) + c
Solution:
(c)
Samacheer Kalvi 11th Maths Solutions Chapter 11 Integral Calculus Ex 11.13 9

Question 6.
\(\int \frac{\sqrt{\tan x}}{\sin 2 x} d x\) is ……………..
Samacheer Kalvi 11th Maths Solutions Chapter 11 Integral Calculus Ex 11.13 10
Solution:
(a)
Samacheer Kalvi 11th Maths Solutions Chapter 11 Integral Calculus Ex 11.13 11

Question 7.
\(\int \sin ^{3} x d x\) is …………….
Samacheer Kalvi 11th Maths Solutions Chapter 11 Integral Calculus Ex 11.13 12
Solution:
(c)
Hint: sin3x = \(\frac{1}{4}\) (3 sin x – sin 3x)
Samacheer Kalvi 11th Maths Solutions Chapter 11 Integral Calculus Ex 11.13 13

Question 8.
Samacheer Kalvi 11th Maths Solutions Chapter 11 Integral Calculus Ex 11.13 14
Solution:
(b)
Samacheer Kalvi 11th Maths Solutions Chapter 11 Integral Calculus Ex 11.13 15

Question 9.
Samacheer Kalvi 11th Maths Solutions Chapter 11 Integral Calculus Ex 11.13 16
(a) tan-1 (sin x) + c
(b) 2 sin-1 (tan x) + c
(c) tan-1 (cos x) + c
(d) sin-1 (tan x) + c
Solution:
(d)
Samacheer Kalvi 11th Maths Solutions Chapter 11 Integral Calculus Ex 11.13 17
= sin-1 (t) + c
= sin-1 (tan x) + c

Samacheer Kalvi 11th Maths Solutions Chapter 11 Integral Calculus Ex 11.13

Question 10.
Samacheer Kalvi 11th Maths Solutions Chapter 11 Integral Calculus Ex 11.13 18
(a) x2 + c
(b) 2x2 + c
(c) \(\frac{x^{2}}{2}\) + c
(d) \(-\frac{x^{2}}{2}\) + c
Solution:
(c)
Samacheer Kalvi 11th Maths Solutions Chapter 11 Integral Calculus Ex 11.13 19

Question 11.
\(\int 2^{3 x+5} d x\) is ……………
Samacheer Kalvi 11th Maths Solutions Chapter 11 Integral Calculus Ex 11.13 20
Solution:
(d)
Samacheer Kalvi 11th Maths Solutions Chapter 11 Integral Calculus Ex 11.13 21

Question 12.
Samacheer Kalvi 11th Maths Solutions Chapter 11 Integral Calculus Ex 11.13 22
Solution:
(b)
Samacheer Kalvi 11th Maths Solutions Chapter 11 Integral Calculus Ex 11.13 23

Question 13.
Samacheer Kalvi 11th Maths Solutions Chapter 11 Integral Calculus Ex 11.13 24
Solution:
(d)
Samacheer Kalvi 11th Maths Solutions Chapter 11 Integral Calculus Ex 11.13 25

Question 14.
\(\int \frac{x^{2}+\cos ^{2} x}{x^{2}+1}\) cosec2xdx is …………….
(a) cot x + sin-1 x + c
(b) -cot x + tan-1 x + c
(c) -tan x + cot-1 x + c
(d) -cot x – tan-1 x + c
Solution:
(d)
Samacheer Kalvi 11th Maths Solutions Chapter 11 Integral Calculus Ex 11.13 26

Question 15.
\(\int x^{2} \cos x d x\) is ……………
(a) x2 sin x + 2x cos x – 2 sin x + c
(b) x2 sin x – 2x cos x – 2 sin x + c
(c) -x2 sin x + 2x cos x + 2 sin x + c
(d) -x2 sin x – 2x cos x + 2 sin x + c
Solution:
(a)
Hint: \(\int x^{2} \cos x d x\)
By Bernoullis formula dv = cosxdx
u = x2 v = sinx
u’ = 2x v1 = -cos x
u” = 2 v2 = -sinx
= uv – u’v1 + u”v2
= x2sin x + 2x cos x – 2 sin x + c

Samacheer Kalvi 11th Maths Solutions Chapter 11 Integral Calculus Ex 11.13

Question 16.
Samacheer Kalvi 11th Maths Solutions Chapter 11 Integral Calculus Ex 11.13 27
Solution:
(b)
Samacheer Kalvi 11th Maths Solutions Chapter 11 Integral Calculus Ex 11.13 28

Question 17.
\(\int \frac{d x}{e^{x}-1}\) is …………….
(a) log |ex| – log |ex – 1| + c
(b) log |ex| + log |ex – 1| + c
(c) log |ex – 1| – log |ex| + c
(d) log |ex + 1| – log |ex| + c
Solution:
(c)
Samacheer Kalvi 11th Maths Solutions Chapter 11 Integral Calculus Ex 11.13 29

Question 18.
Samacheer Kalvi 11th Maths Solutions Chapter 11 Integral Calculus Ex 11.13 30
Solution:
(b)
We know that
Samacheer Kalvi 11th Maths Solutions Chapter 11 Integral Calculus Ex 11.13 31

Question 19.
Samacheer Kalvi 11th Maths Solutions Chapter 11 Integral Calculus Ex 11.13 32
Solution:
(d)
Samacheer Kalvi 11th Maths Solutions Chapter 11 Integral Calculus Ex 11.13 33

Question 20.
Samacheer Kalvi 11th Maths Solutions Chapter 11 Integral Calculus Ex 11.13 34
Solution:
(a)
We know that
Samacheer Kalvi 11th Maths Solutions Chapter 11 Integral Calculus Ex 11.13 35

Samacheer Kalvi 11th Maths Solutions Chapter 11 Integral Calculus Ex 11.13

Question 21.
Samacheer Kalvi 11th Maths Solutions Chapter 11 Integral Calculus Ex 11.13 36
Solution:
(c)
Hint:
Samacheer Kalvi 11th Maths Solutions Chapter 11 Integral Calculus Ex 11.13 37
By Bernoullis formula,
Samacheer Kalvi 11th Maths Solutions Chapter 11 Integral Calculus Ex 11.13 38

Question 22.
Samacheer Kalvi 11th Maths Solutions Chapter 11 Integral Calculus Ex 11.13 39
Solution:
(d)
Samacheer Kalvi 11th Maths Solutions Chapter 11 Integral Calculus Ex 11.13 40

Question 23.
Samacheer Kalvi 11th Maths Solutions Chapter 11 Integral Calculus Ex 11.13 41
Solution:
(c)
Samacheer Kalvi 11th Maths Solutions Chapter 11 Integral Calculus Ex 11.13 42
Samacheer Kalvi 11th Maths Solutions Chapter 11 Integral Calculus Ex 11.13 43

Question 24.
Samacheer Kalvi 11th Maths Solutions Chapter 11 Integral Calculus Ex 11.13 44
Solution:
(a)
Samacheer Kalvi 11th Maths Solutions Chapter 11 Integral Calculus Ex 11.13 45

Question 25.
Samacheer Kalvi 11th Maths Solutions Chapter 11 Integral Calculus Ex 11.13 46
Solution:
(d)
Hint: Let I = \(\int e^{\sqrt{x}} d x\)
t = \(\sqrt{x}\)
Samacheer Kalvi 11th Maths Solutions Chapter 11 Integral Calculus Ex 11.13 47

Must Follow:

ICICIBANK Pivot Point Calculator

Samacheer Kalvi 8th Maths Solutions Term 3 Chapter 1 Numbers Ex 1.2

Students can Download Maths Chapter 1 Numbers Ex 1.2 Questions and Answers, Notes Pdf, Samacheer Kalvi 8th Maths Book Solutions Guide Pdf helps you to revise the complete Tamilnadu State Board New Syllabus and score more marks in your examinations.

Tamilnadu Samacheer Kalvi 8th Maths Solutions Term 3 Chapter 1 Numbers Ex 1.2

Question 1.
Fill in the blanks:
(i) If a number has 5 or 6 digits in it then, its square root will have………digits.
(ii) The value of 180 lies between integers………and……….
(iii) \(\sqrt{10}\) × \(\sqrt{6}\) × \(\sqrt{15}\) =……………
(iv) \(\frac{\sqrt{300}{\sqrt{192}}\) =…………….
(v) \(\sqrt{65.61}\) =…………….
Solution:
(i) 3
(ii) 13, 14
(iii) 30
(iv) \(\frac{5}{4}\)
(v) 8.1

Samacheer Kalvi 8th Maths Solutions Term 3 Chapter 1 Ex 1.2

Question 2.
Estimate the value of the following square roots to the nearest whole number:
(i) \(\sqrt{440}\)
(ii) \(\sqrt{800}\)
(iii) \(\sqrt{1020}\)
Solution:
(i) We have 20² = 400
21² = 441
∴ \(\sqrt{440}\)  \(\widetilde { – } \) 21

(ii) We have 28² = 784
29² = 841
∴ \(\sqrt{800}\) \(\widetilde { – } \) 28

(iii) We have 31² = 961
32² = 1024
∴ \(\sqrt{1020}\) \(\widetilde { – } \) = 32

Question 3.
Find the least number that must be added to 1300 so as to get a perfect square. Also find the square root of the perfect square.
Solution:
We work out the process of finding square root by long division method.
The given number is 1300
Samacheer Kalvi 8th Maths Solutions Term 3 Chapter 1 Numbers Ex 1.2 1
So we have 36² < 1300 < 37²
Also 1300 is (469 – 400) = 69 less than 37². So if we add 69 to 1300 it will be perfect square. Hence the required, least number is 69 and the perfect square number is 1300 + 69 = 1369
Samacheer Kalvi 8th Maths Solutions Term 3 Chapter 1 Numbers Ex 1.2 2
∴ \(\sqrt{1369}\) = 37

Question 4.
Find the least number that must be subtracted to 6412 so as to get a perfect square. Also find the square root of the perfect square.
Solution:
Let us work out the process of finding the square root of 6412 by long division method.
Samacheer Kalvi 8th Maths Solutions Term 3 Chapter 1 Numbers Ex 1.2 3
The remainder in the last step is 12. Is if 12 be subtracted from the given number the remainder will be zero and the new number will be a perfect square.
∴ The required number is 12.
The square number is 6412 – 12 = 6400
Also \(\sqrt{6400}\) = 80

Question 5.
Find the square root by long division method.
(i) 17956
(ii) 11025
(iii) 6889
(iv) 1764
(v) 418609
Solution:
Samacheer Kalvi 8th Maths Solutions Term 3 Chapter 1 Numbers Ex 1.2 4
Samacheer Kalvi 8th Maths Solutions Term 3 Chapter 1 Numbers Ex 1.2 5

Samacheer Kalvi 8th Maths Solutions Term 3 Chapter 1 Ex 1.2

Question 6.
Find the square root of the following decimal numbers:
(i) 2.89
(ii) 1.96
(iii) 67.24
(iv) 31.36
(v) 2.0164
(vi) 13.9876
Solution:
Samacheer Kalvi 8th Maths Solutions Term 3 Chapter 1 Numbers Ex 1.2 6

Question 7.
Find the square root of each of the following fractions:
(i) \(\frac{144}{225}\)
(ii) 7\(\frac{18}{49}\)
(iii) 6\(\frac{1}{4}\)
(iv) 4\(\frac{25}{36}\)
Solution:
Samacheer Kalvi 8th Maths Solutions Term 3 Chapter 1 Numbers Ex 1.2 7
Samacheer Kalvi 8th Maths Solutions Term 3 Chapter 1 Numbers Ex 1.2 8

Question 8.
Say True or False:
(i) \(\frac{\sqrt{32}}{\sqrt{8}}=2\)
(ii) \(\sqrt{\frac{625}{1024}}=\frac{25}{32}\)
(iii) \(\sqrt{28}{7}=2\sqrt{7}\)
(iv) \(\sqrt{225}{64}=\sqrt{289}\)
(v) \(\sqrt{1 \frac{400}{441}}=1 \frac{20}{21}\)
Solution:
(i) true
(ii) true
(iii) false
(iv) false
(v) false

Objective Type Questions

Question 9.
\(\sqrt{48}\) is approximately equal to
(a) 5
(b) 6
(c) 7
(d) 8
Solution:
(c) 7
Hint:
\(\sqrt{49}\) = 7

Samacheer Kalvi 8th Maths Solutions Term 3 Chapter 1 Ex 1.2

Question 10.
\(\sqrt{128}\) – \(\sqrt{98}\) + \(\sqrt{18}\) =
(a) \(\sqrt{2}\)
(b) \(\sqrt{8}\)
(c) \(\sqrt{48}\)
(d) \(\sqrt{32}\)
Solution:
(d) \(\sqrt{32}\)
Hint:
\(\sqrt{128}-\sqrt{98}+\sqrt{18}=8 \sqrt{2}-7 \sqrt{2}+3 \sqrt{2}=4 \sqrt{2}=\sqrt{32}\)

Question 11.
\(\sqrt{22+\sqrt{7+\sqrt{4}}}=\)
(a) \(\sqrt{25}\)
(b) \(\sqrt{33}\)
(c) \(\sqrt{31}\)
(d) \(\sqrt{29}\)
Solution:
(a) \(\sqrt{25}\)
Hint:
\(\sqrt{22+\sqrt{7+\sqrt{4}}}=\sqrt{22+\sqrt{7+2}}=\sqrt{22+3}=\sqrt{25}\)

Question 12.
The number of digits in the square root of 123454321 is
(a) 4
(b) 5
(c) 6
(d) 7
Solution:
(b) 5
Hint:
\(=\frac{n+1}{2}=\frac{10}{2}=5\)