12th Standard Syllabus & Materials
12th Standard
TN 12th Computer Applications மின்னணு தரவு பரிமாற்றம் Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Computer Applications மின் - வணிக பாதுகாப்பு அமைப்புகள் Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Computer Applications மின்னணு செலுத்தல் முறைகள் Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Computer Applications மின் - வணிகம் Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Computer Applications திறந்த மூல கருத்துருக்கள் Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Computer Applications வலையமைப்பு வடமிடல் Sample Question Papers Study Material - QB365 Set A

Published on: 03/02/2021
12th Standard Computer Science English Medium Python Functions Reduced Syllabus Important Questions With Answer key 2021
Download Tamil Nadu 12th Standard Computer Science question papers, model tests, one-mark questions, important questions, and public exam papers in PDF format. Free study materials and answer keys for TN State Board students.
Questions + Answers key
Take MCQ Computer Science Test

1.
_____ is applied in any recursive function is known as base condition.
Finite iteration
Default arguments
Keyword arguments
Infinite iteration
2.
You can convert any loop to ______
Recursion
Composition
Function
Branching
3.
____ works like loop.
Function
Recursion
Composition
Specification
4.
A _____ variable only exists while the function is executing.
global
local
file
function
5.
When a variable is created inside the _____ the variable becomes local to it.
program
function
block
global
6.
The __ arguments are also local to function
default
keyword
format
variable-length
7.
While defining syntax the text which is given in _____ is optional.
()
<>
[]
{}
8.
Which function is inverse of chr () function?
type ()
id ()
formula ()
ord ()
9.
Which function is mostly used for creating small and one time anonymous function?
Synchronous
Lambda
User-defined
Built-in
10.
Which function can take any number of arguments and must return one value in the form of an expression?
user defined
recursive
lambda
default
11.
Which of the following is not a type of function in python?
Control
Lambda
Recursion
Built in
12.
How many types of functions are there in python?
3
4
2
5
13.
Which of the following keyword is used to define the function testpython(): ?
define
pass
def
while
14.
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.
I is correct and II is wrong
Both are correct
I is wrong and II is correct
Both are wrong
15.
A Function which calls itself is called as
Built-in
Recursion
Lambda
return
16.
Write the output for the following.
(i) Print (ord ('a')
(ii) Print (chr (65))
(iii) Print (bin (15))
(iv) Print (format (15,'b'))
17.
How the value returned from lambda function?
18.
What is anonymous function or lambda function?
19.
What are called tuples?
20.
What are arguments? What are the types?
21.
Write the syntax for passing arguments to functions.
22.
How the nested block are indented?
23.
How the statements in a black are written in python?
24.
How to set the limit for recursive function? Give an example.
25.
What are the main advantages of function?
26.
Write a note on (i) floor (), (ii) ceil (), (iii) Sprt ().
27.
Write a note of return statement.
28.
How python takes a default value in the function call? Explain with an example.
29.
How will you invoke the function after, the parameters are recognized by their parameter names? Explain with an example.
30.
What are the points to be noted while defining a function?
31.
How recursive function works?
32.
What is composition in functions?
33.
34.
What happens when we modify global variable inside the function?
35.
Write the rules of local variable.
36.
Write a python program to find Fibonacci series of n terms using recursion.
37.
Write a python program to find HCF of two numbers using recursion.
38.
Explain different types arguments used in python with an example.
39.
Explain recursive function with an example.
40.
Write a Python code to find the L.C.M. of two numbers.
41.
Explain the following built-in functions.
(a) id ()
(b) chr ()
(c) round ()
(d) type ()
(e) pow ()
42.
Explain the different types of function with an example.
1.
(d)
Infinite iteration
2.
(a)
Recursion
3.
(b)
Recursion
4.
(b)
local
5.
(b)
function
6.
(c)
format
7.
(c)
[]
8.
(d)
ord ()
9.
(b)
Lambda
10.
(c)
lambda
11.
(a)
Control
12.
(b)
4
13.
(c)
def
14.
(a)
I is correct and II is wrong
15.
(b)
Recursion
16.
(i) 97
(ii) A
(iii) ob 1111
(iv) 1111
17.
Lambda function can take any number of arguments and must return one value in the form of an expression.
18.
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.
19.
Non-keyword variable arguments are called tuples.
20.
Arguments are used to call a function and there are primarily 4 types of functions. They are: Required arguments, Keyword arguments, Default arguments and Variable-length arguments.
21.
Syntax:
def function_name (parameter(s) separated by comma):
22.
A block within a block is called nested block. When the first block statement is indented by a single table space, the second block of statement is indented-by double tab spaces.
23.
In Python, statements in a block are written with indentation.
24.
(i) Python stops calling recursive function after 1000 calls by default.
(ii) So, it 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))
25.
Main advantages of functions are
(i) It avoids repetition and makes a high degree of code reusing.
(ii) It provides better modularity for your application.
26.
| Function | Description | Syntax | Example |
| floor () | Returns the largest integer less than or equal to x |
math.floor (x) | x=26.7 print (math.floor (x)) Output: 26 |
| ceil () | Returns the smallest integer greater than or equal to x |
math.ceil (x) | x= 26.7 print (math.ceil (x)) Output: 37 |
| sqrt () | Returns the square root of x Note: must be greater than 0 (zero) |
sqrt (x) |
b=49 Output: |
27.
The return statement:
(i) The return statement causes your function to exit and returns a value to its caller. The it point of functions in general is to take inputs and return something.
(ii) 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.
(iii) Any number of 'return' statements are allowed in a function definition but only one of them is executed at run time.
28.
(i) In Python the default argument is an argument that takes a default value if no value is provided in the function call.
(ii) The following example uses default arguments, that prints default salary when no argument is passed.
(iii) Example:
def printinfo( name, salary = 3500):
print ("Name: ", name)
print ("Salary: ", salary)
return
printinfo("Mani")
When the above code is executed, it produces the following output
Output:
Name: Mani
Salary: 3500
When the above code is changed as print info("Ram", 2000) it produces the following output:
Output:
Name: Ram
Salary: 2000
29.
(i) Keyword arguments will invoke the function after the parameters are recognized by their parameter names.
(ii) The value of the keyword argument is matched with the parameter name and so, one can also put arguments in improper order.
(iii) Example:
def printdata (name):
print ("Example-1 Keyword arguments")
print ("Name :",name)
return
# Now you can call printdatat() function
printdata(name = "Gshan")
When the above code is executed, it produces the following output:
Output:
Example-1 Keyword arguments
Name: Gshan
30.
When defining functions there are multiple things that need to be noted;
(i) Function blocks begin with the keyword "def" followed by function name and parenthesis ().
(ii) If any input parameters are present should be placed within these parentheses when you define a function.
(iii) The code block always comes after colon(:) and is indented.
(iv) 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.
31.
(i) Recursive function is called by some external code.
(ii) If the base condition is met then the program gives meaningful output and exits.
(iii) Otherwise, function does some required processing and then calls itself to continue recursion.
32.
(i) The value returned by a function may be used as an argument for another function in a nested manner.
(ii) 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.
33.
34.
If we modify the global variable, we can see the change on the global variable outside the function also.
Example:
x=0 # global variable
def add():
global x
x=x+5 # increment by 5
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 #value of x changed outside the function
35.
Rules of local variable:
(i) A variable with local scope can be accessed only within the function/block that it is created in.
(ii) When a variable is created inside the function the variable becomes local to it.
(iii) A local variable only exists while the function is executing.
(iv) The formal parameters are also local to function.
36.
# program to find fibonacci series
def fibo (n):
if n < = 1:
return n
else:
return (fibo (n - 1) + fibo (n - 2))
n = int (input ("Enter How manu terms"))
for i in range (n):
print (fibo (i))
37.
# python program to find HCF
def HCF (x,y):
if(x > y):
s = y
else:
s = x
for I inrange (1, s + 1):
if ((x % I = = 0) and (y% i = = 0)):
hcf = i
return hcf
x = int (input ("Enter Number 1"))
y = int (input ("Enter Number 2"))
print (HCF (x, y))
38.
(i) Required Arguments:
"Required Arguments" are the arguments passed to a function in correct positional order. Here, the number of arguments in the function call should match exactly with the function definition. Atleast one parameter to prevent syntax errors to get the required output.
(ii) Example:
def printstring(str):
print ("Example - Required arguments")
print (str)
return
# Now you can call printstring() function
printstring ("Welcome")
Output:
Example - Required arguments
Welcome
(iii) When the above code is executed, it produces the following error.
Traceback (most recent call last):
File "Req-arg.py", line 10, in
printstring()
TypeError: printstring() missing 1 required positional argument: 'str'
(iv) Instead of printstring() in the above code if we use printstring ("Welcome") then the output is
Output:
Example - Required arguments
Welcome
Keyword Arguments:
Keyword arguments will invoke the function after the parameters are recognized by their parameter names. The value of the keyword argument is matched with the parameter name and so, one can also put arguments in improper order (not in order).
(ii) Example:
def printdata (name):
print ("Example-1 Keyword arguments")
print ("Name :":name)
return
# Now you can call printdatat() function
printdata(name = "Gshan")
(iii) When the above code is executed, it produces the following output:
Output:
Example-1 Keyword arguments
Name:Gshan
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.
Example:
def printinfo( name, salary = 3500):
print ("Name: ", name)
print ("Salary: ", salary)
return
printinfo("Mani")
(iii) When the above code is executed, it produces the following output
Output:
Name: Mani
Salary: 3500
(iv) When the above code is changed as print info("Ram,":2000) it produces the following output:
Output:
Name: Ram
Salary: 2000
Syntax - Variable-Length Arguments:
(i) def function_name(*args):
function_body
return_statement
(ii) Example:
def printnos (*nos):
for n in nos:
print(n)
return
# now invoking the printnos() function
print ('Printing two values')
printnos (1,2)
print ('Printing three values')
printnos (10,20,30)
Output:
Printing two values
1
2
Printing three values
10
20
30
39.
(i) When a function calls itself is known as recursion.
(ii) Recursion works like loop but sometimes it makes more sense to use recursion than loop.
(iii) You can convert any loop to recursion. A recursive function calls itself.
(iv) Imagine a process would iterate indefinitely if not stopped by some condition is known as infinite iteration.
(v) The condition that is applied in any recursive function is known as base condition.
(vi) A base condition is must in every recursive function otherwise it will continue to execute like an infinite loop.
Overview of how recursive function works:
(i) Recursive function is called by some external code.
(ii) If the base condition is met then the program gives meaningful output and exits.
(iii) Otherwise, function does some required processing and then calls itself to continue recursion.
Here is an exanmple 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:
120
40.
Program:
def lcm(x, y):
if x>y:
greater = x
else:
greater = y
while (True):
if ((greater % x == 0) and (greater % y ==0))
lcm = greater
break
greater + = 1
return lcm
a = int (input ("Enter the first number:"))
b = int (input ("Enter the second number: "))
print ("The L.C.M of", a, "and", b, "is", lcm (a, b))
[OR]
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
41.
| Function | Description | Syntax | Example |
| (a) id() | id () Return the "identity" of an objects i.e. The address of the object in memory. Note: The address of x and y may differ in your system. |
id(object) | x = 15 y = 'a' print('address of x is :',id(x)) print ('address of y is :',id (y)) Output: address of x is: 1357486752 address of y is: 13480736 |
| (b) Chr() | Returns the Unicode character for the given ASCII value. This function is inverse of ord() function. | Chr(i) | c=65 d=43 print(chr(c)) print(chr(d)) Output: A + |
| (c) round() | Returns the nearest integer to its input. 1. First argument(number) is used to specify the value to be rounded. |
round (number, [ndigits]) | x = 17.9 y = 22.2 z = -18.3 print('x value is rounded to', round(x)) print('y value ic rounded to', round(y)) print ('z value is rounded to', round(z)) |
| (d) type() | Returns the type of object for the given single object. Note: This function used with single object parameter. |
type(object) | x = 15.2 y = 'a' s = true print(type(x)) print(type(y)) print(type(s)) Output: < class 'float' > < class 'str' > < class 'bool' > |
| (e) pow() | Returns the computation of ab i.e. (a**b) a raised to the power of b. | pow(a, b) | a = 5 b = 2 c = 3.0 print(pow(a, b)) print(pow(a, c)) print(pow(a + b, 3)) Output: 25 125.0 343 |
42.
Functions are named blocks of code that are designed to do one specific job.
Types of Functions :
(i) User-defined Functions
(ii) Built-in Functions
(iii) Lambda Functions
(iv) Recursion Function
User defined functions:
1. Functions defined by the users themselves are called user defined function.
2. Functions must be defined, to create and use certain functionality.
3.Function blocks begin with the keyword "def" followed by function name and parenthesis ().
Syntax:
def
return
def hello ():
print ("hello Python")
return
Built-in function: Functions which are using Python libraries are called Built-in function.
x = 20
y = 23.2
print('x=',abs(x))
print ('y=', abs(y))
Output:
x = 20
y = 23.2
Lambda function :
1. In Python, anonymous function is a function that is defined without a name.
2. While normal functions are defined using the def keyword, in Python anonymous functions are defined using the lambda keyword.
3.Hence anonymous functions are also called as lambda functions.
Example:
Sum =lambda arg1, arg 2: arg 1 + arg 2
print ("The sum is:", sum (30,40))
print ("The sum is:", sum (-30,40))
Output:
The sum is: 70
The sum is: 10
Recursion Function: Function that calls itself is known as recursive.
Overview of how recursive function works :
(a) Recursive function is called by some external code.
(b) If the base condition is met then the program gives meaningful output and exits.
(c) Otherwise, function does some required processing and then calls itself to continue 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
12th Standard Syllabus & Materials
12th Standard
TN 12th Computer Applications களப்பெயர் முறைமை (DNS) Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Computer Applications வலையமைப்பு எடுத்துக்காட்டுகள் மற்றும் நெறிமுறைகள் Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Computer Applications கணினி வலையமைப்பு ஓர் அறிமுகம் Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Computer Applications PHP-உடன் MySQL-ஐ இணைத்தல் Sample Question Papers Study Material - QB365 Set A
Tamilnadu Stateboard 12th Standard Subjects

Maths

Chemistry

Physics

Biology

Computer Science

Business Maths and Statistics

Economics

Commerce

Accountancy

History

Computer Applications

Biology

Computer Technology

Computer Applications

Computer Science

Business Maths and Statistics

Commerce

Economics

Maths

Chemistry

Physics

Computer Technology

History

Accountancy

Tamil

English

French
Tamilnadu Stateboard Standards