This is only for Sample
for Full Book Order online and Available at all Leading Bookstores
Namma Kalvi
www.nammakalvi.in
COMPUTER SCIENCE
m
co
12th Standard
s.
Based on the New Syllabus and
ok
New Textbook for the year 2019-20
o
Salient Features
ab
Exhaustive Additional MCQs, VSA and SA question with
answers are given in each chapter.
All the objective type (1 Mark) questions are given with 4
options.
ur
(i) Choosing the correct option
(ii) Matching
(iii) Filling the blanks
.s
(iv) Choosing the Correct\Incorrect Statement.
w
w
w
SURA PUBLICATIONS
Chennai
PH: / 8124301000
, This is only for Sample
for Full Book Order online and Available at all Leading Bookstores
UNIT-I
PROBLEM SOLVING TECHNIQUES
1
Chapter
FUNCTION
m
co
s.
CHAPTER SNAPSHOT
ok
1.1 Introduction
1.2 Function with respect to Programming language
1.2.1 Function Specification
1.2.2 Parameters (and arguments)
o
1.3 Interface vs Implementation
1.4 Pure functions
ab
1.4.1 Impure functions
1.4.2 Side-effects (Impure functions)
1.4.3 Chameleons of Chromeland problem using function
ur
.s
w
w
w
[1]
PH: / 8124301000
, This is only for Sample
Unit I - Chapter 1
Sura’s ➠ XII Std - Computer Science
Evaluation
for Full Book Order online and Available at all Leading Bookstores
8. Which of the following carries out the
Part - I instructions defined in the interface?
Choose the best answer (1 mark) (a) Operating System (b) Compiler
m
(c) Implementation (d) Interpreter
1. The small sections of code that are used to [Ans. (c) Implementation]
perform a particular task is called
(a) Subroutines (b) Files 9. The functions which will give exact result
co
(c) Pseudo code (d) Modules when same arguments are passed are called
[Ans. (a) subroutines] (a) Impure functions (b) Partial Functions
(c) Dynamic Functions (d) Pure functions
2. Which of the following is a unit of code that is [Ans. (d) Pure functions]
often defined within a greater code structure?
s.
(a) Subroutines (b) Function 10. The functions which cause side effects to the
arguments passed are called
(c) Files (d) Modules
(a) impure function (b) Partial Functions
[Ans. (b) Function]
ok
(c) Dynamic Functions (d) Pure functions
3. Which of the following is a distinct syntactic [Ans. (a) impure function]
block?
Part - II
(a) Subroutines (b) Function
(c) Definition (d) Modules
Answer the following questions
o
[Ans. (c) Definition] (2 marks)
4. The variables in a function definition are
ab
1. What is a subroutine?
called as
Ans. (i) Subroutines are the basic building blocks of
(a) Subroutines (b) Function computer programs. Subroutines are small
(c) Definition (d) Parameters sections of code that are used to perform a
[Ans. (d) Parameters] particular task that can be used repeatedly.
ur
5. The values which are passed to a function (ii) In Programming languages these
definition are called subroutines are called as Functions.
(a) Arguments (b) Subroutines 2. Define Function with respect to Programming
.s
(c) Function (d) Definition language.
[Ans. (a) Arguments] Ans. A function is a unit of code that is often defined
within a greater code structure. Specifically, a
6. Which of the following are mandatory to function contains a set of code that works on
w
write the type annotations in the function many kinds of inputs, like variants, expressions
definition? and produces a concrete output.
(a) Curly braces (b) Parentheses
w
(c) Square brackets (d) indentations 3. Write the inference you get from X:=(78).
[Ans. (b) Parentheses] Ans. X:= (78) has an expression in it but (78) is not
itself an expression. Rather, it is a function
7. Which of the following defines what an object definition. Definitions bind values to names,
w
can do? in this case the value 78 being bound to the
(a) Operating System (b) Compiler name ‘X’. Definitions are not expressions, at
(c) Interface (d) Interpreter the same time expressions are also not treated
[Ans. (c) Interface] as definitions. Definitions are distinct syntactic
blocks. Definitions can have expressions nested
inside them, and vice-versa.
2
PH: / 8124301000
, This is only for Sample
for Full Book Order online and Available at all Leading Bookstores
Sura’s ➠ XII Std - Computer Science
4. Differentiate interface and implementation. 3. What is the side effect of impure function.
Ans. The difference between interface and Give example.
Function
implementation is Ans. (i) The variables used inside the function may
Interface Implementation cause side effects though the functions
Interface just Implementation carries which are not passed with any arguments.
m
defines what an out the instructions In such cases the function is called impure
object can do, but defined in the interface function.
won't actually do it (ii) When a function depends on variables or
functions outside of its definition block,
co
5. Which of the following is a normal function
you can never be sure that the function will
definition and which is recursive function
behave the same every time it’s called.
definition.
i) let rec sum x y : (iii) For example the mathematical function
random() will give different outputs for the
return x + y
s.
same function call.
ii) let disp :
Program :
print 'welcome'
let Random number
iii) let rec sum num :
ok
let a := random()
if (num!=0) then return num + sum
if a > 10 then
(num-1)
return: a
else
else
return num
o
return: 10
Ans. (i) Recursive function
(iv) Here the function Random is impure as it
(ii) Normal function
ab
is not sure what will be the result when we
(iii) Recursive function call the function.
Part - III 4. Differentiate pure and impure function.
Answer the following questions Ans.
ur
(3 marks) Interface Implementation
The return value of The return value
1. Mention the characteristics of Interface. the pure functions of the impure
Ans. (i) The class template specifies the interfaces to solely depends on its functions does not
.s
enable an object to be created and operated arguments passed. solely depend on its
properly. Hence, if you call arguments passed.
(ii) An object's attributes and behaviour is the pure functions Hence, if you call the
w
controlled by sending functions to the with the same set of impure functions
object. arguments, you will with the same set of
always get the same arguments,
2. Why strlen is called pure function? return values. you might get the
w
Ans. (i) strlen is a pure function because the They do not have any different return
function takes one variable as a parameter, side effects. values. For example,
and accesses it to find its length. random(), Date().
w
(ii) This function reads external memory but They do not modify They may modify the
does not change it, and the value returned the arguments which arguments which are
derives from the external memory accessed. are passed to them passed to them
3
PH: / 8124301000
for Full Book Order online and Available at all Leading Bookstores
Namma Kalvi
www.nammakalvi.in
COMPUTER SCIENCE
m
co
12th Standard
s.
Based on the New Syllabus and
ok
New Textbook for the year 2019-20
o
Salient Features
ab
Exhaustive Additional MCQs, VSA and SA question with
answers are given in each chapter.
All the objective type (1 Mark) questions are given with 4
options.
ur
(i) Choosing the correct option
(ii) Matching
(iii) Filling the blanks
.s
(iv) Choosing the Correct\Incorrect Statement.
w
w
w
SURA PUBLICATIONS
Chennai
PH: / 8124301000
, This is only for Sample
for Full Book Order online and Available at all Leading Bookstores
UNIT-I
PROBLEM SOLVING TECHNIQUES
1
Chapter
FUNCTION
m
co
s.
CHAPTER SNAPSHOT
ok
1.1 Introduction
1.2 Function with respect to Programming language
1.2.1 Function Specification
1.2.2 Parameters (and arguments)
o
1.3 Interface vs Implementation
1.4 Pure functions
ab
1.4.1 Impure functions
1.4.2 Side-effects (Impure functions)
1.4.3 Chameleons of Chromeland problem using function
ur
.s
w
w
w
[1]
PH: / 8124301000
, This is only for Sample
Unit I - Chapter 1
Sura’s ➠ XII Std - Computer Science
Evaluation
for Full Book Order online and Available at all Leading Bookstores
8. Which of the following carries out the
Part - I instructions defined in the interface?
Choose the best answer (1 mark) (a) Operating System (b) Compiler
m
(c) Implementation (d) Interpreter
1. The small sections of code that are used to [Ans. (c) Implementation]
perform a particular task is called
(a) Subroutines (b) Files 9. The functions which will give exact result
co
(c) Pseudo code (d) Modules when same arguments are passed are called
[Ans. (a) subroutines] (a) Impure functions (b) Partial Functions
(c) Dynamic Functions (d) Pure functions
2. Which of the following is a unit of code that is [Ans. (d) Pure functions]
often defined within a greater code structure?
s.
(a) Subroutines (b) Function 10. The functions which cause side effects to the
arguments passed are called
(c) Files (d) Modules
(a) impure function (b) Partial Functions
[Ans. (b) Function]
ok
(c) Dynamic Functions (d) Pure functions
3. Which of the following is a distinct syntactic [Ans. (a) impure function]
block?
Part - II
(a) Subroutines (b) Function
(c) Definition (d) Modules
Answer the following questions
o
[Ans. (c) Definition] (2 marks)
4. The variables in a function definition are
ab
1. What is a subroutine?
called as
Ans. (i) Subroutines are the basic building blocks of
(a) Subroutines (b) Function computer programs. Subroutines are small
(c) Definition (d) Parameters sections of code that are used to perform a
[Ans. (d) Parameters] particular task that can be used repeatedly.
ur
5. The values which are passed to a function (ii) In Programming languages these
definition are called subroutines are called as Functions.
(a) Arguments (b) Subroutines 2. Define Function with respect to Programming
.s
(c) Function (d) Definition language.
[Ans. (a) Arguments] Ans. A function is a unit of code that is often defined
within a greater code structure. Specifically, a
6. Which of the following are mandatory to function contains a set of code that works on
w
write the type annotations in the function many kinds of inputs, like variants, expressions
definition? and produces a concrete output.
(a) Curly braces (b) Parentheses
w
(c) Square brackets (d) indentations 3. Write the inference you get from X:=(78).
[Ans. (b) Parentheses] Ans. X:= (78) has an expression in it but (78) is not
itself an expression. Rather, it is a function
7. Which of the following defines what an object definition. Definitions bind values to names,
w
can do? in this case the value 78 being bound to the
(a) Operating System (b) Compiler name ‘X’. Definitions are not expressions, at
(c) Interface (d) Interpreter the same time expressions are also not treated
[Ans. (c) Interface] as definitions. Definitions are distinct syntactic
blocks. Definitions can have expressions nested
inside them, and vice-versa.
2
PH: / 8124301000
, This is only for Sample
for Full Book Order online and Available at all Leading Bookstores
Sura’s ➠ XII Std - Computer Science
4. Differentiate interface and implementation. 3. What is the side effect of impure function.
Ans. The difference between interface and Give example.
Function
implementation is Ans. (i) The variables used inside the function may
Interface Implementation cause side effects though the functions
Interface just Implementation carries which are not passed with any arguments.
m
defines what an out the instructions In such cases the function is called impure
object can do, but defined in the interface function.
won't actually do it (ii) When a function depends on variables or
functions outside of its definition block,
co
5. Which of the following is a normal function
you can never be sure that the function will
definition and which is recursive function
behave the same every time it’s called.
definition.
i) let rec sum x y : (iii) For example the mathematical function
random() will give different outputs for the
return x + y
s.
same function call.
ii) let disp :
Program :
print 'welcome'
let Random number
iii) let rec sum num :
ok
let a := random()
if (num!=0) then return num + sum
if a > 10 then
(num-1)
return: a
else
else
return num
o
return: 10
Ans. (i) Recursive function
(iv) Here the function Random is impure as it
(ii) Normal function
ab
is not sure what will be the result when we
(iii) Recursive function call the function.
Part - III 4. Differentiate pure and impure function.
Answer the following questions Ans.
ur
(3 marks) Interface Implementation
The return value of The return value
1. Mention the characteristics of Interface. the pure functions of the impure
Ans. (i) The class template specifies the interfaces to solely depends on its functions does not
.s
enable an object to be created and operated arguments passed. solely depend on its
properly. Hence, if you call arguments passed.
(ii) An object's attributes and behaviour is the pure functions Hence, if you call the
w
controlled by sending functions to the with the same set of impure functions
object. arguments, you will with the same set of
always get the same arguments,
2. Why strlen is called pure function? return values. you might get the
w
Ans. (i) strlen is a pure function because the They do not have any different return
function takes one variable as a parameter, side effects. values. For example,
and accesses it to find its length. random(), Date().
w
(ii) This function reads external memory but They do not modify They may modify the
does not change it, and the value returned the arguments which arguments which are
derives from the external memory accessed. are passed to them passed to them
3
PH: / 8124301000