12th Standard Syllabus & Materials
12th Standard
TN 12th Tamil செல்வத்துள் எல்லாம் தலை - வாழ்வியல் இலக்கியம் - திருக்குறள் Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Tamil எல்லா உயிரும் தொழும் - இலக்கணம் -தொன்மம் Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Tamil எல்லா உயிரும் தொழும் - செய்யுள்-புறநானுறு Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Tamil நாடு சமூகம் திருவாகம் மனிதம் - உரைநடை உலகம் -இலக்கியத்தில் மேலாண்மை Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Tamil அருமை உடைய செயல் -இலக்கணம் -படைப்பாக்க உத்திகள் Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Tamil அருமை உடைய செயல் - துணைப்பாடம் -நடிகர் திலகம் 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 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.
How the value returned from lambda function?
2.
What is anonymous function or lambda function?
3.
What are called tuples?
4.
Write the syntax of variable - length arguments.
5.
Write the output of the following program.
6.
How to set the limit for recursive function? Give an example.
7.
What is base condition in recursive function?
8.
Define global scope.
9.
What are the main advantages of function?
10.
What is function?
11.
Write a note on (i) min (), (ii) max (), (iii) sum ().
12.
What is the use of global keyword? Explain with an example?
13.
How python takes a default value in the function call? Explain with an example.
14.
How will you invoke the function after, the parameters are recognized by their parameter names? Explain with an example.
15.
Write the advantages of user-defined functions.
16.
When do you call the function to perform a specify task?
17.
What are the points to be noted while defining a function?
18.
How recursive function works?
19.
What is composition in functions?
20.
What happens when we modify global variable inside the function?
21.
Write a python program to find Fibonacci series of n terms using recursion.
22.
Write a python program to find HCF of two numbers using recursion.
23.
Explain different types arguments used in python with an example.
24.
Explain recursive function with an example.
25.
Explain the following built-in functions.
(a) id ()
(b) chr ()
(c) round ()
(d) type ()
(e) pow ()
26.
Explain the scope of variables with an example.
27.
Explain the different types of function with an example.
28.
______ function returns the largest integer less than or equal to x.
cell ()
floor ()
pow ()
round ()
29.
You can convert any loop to ______
Recursion
Composition
Function
Branching
30.
____ works like loop.
Function
Recursion
Composition
Specification
31.
The __ function is inverse of ord () function.
id ()
bin ()
chr ()
none of these
32.
The ____ keyword used to read and write a global variable inside a function.
global
local
return
def
33.
In _____ arguments, one can put arguments in improper order.
Default
Keyword
Required
Variable length arguments
34.
The __ arguments are also local to function
default
keyword
format
variable-length
35.
____ of variable refers to the part of the program, where it is accessible.
return
scope
definition
argument
36.
Python _____ should not be used as function name.
Identifiers
Operators
Variables
Keywords
37.
By default python stops calling recursive function after
2000
5000
1000
100
38.
A with local scope can be accessed only within the block
keyword
variable
function
integer
39.
Which of the following functions is an example that supports variable-length arguments?
While
If
Print ()
Input()
40.
In Python, statement in a block are written with
Function
Identification
Recursion
Parameters
41.
Which of the following statement exits a function?
Exit
Def
Return
None of these
42.
Functions that calls itself are known as
User defined
Recursive
Built-in
Lambda
1.
Lambda function can take any number of arguments and must return one value in the form of an expression.
2.
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.
3.
Non-keyword variable arguments are called tuples.
4.
def function_name(*args):
function_body
return_statement
5.
Example:
def hello():
print ("hello - Python")
return
print (hello())
Output:
hello - Python
None
6.
(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))
7.
(i) A recursive function calls itself.
(ii) The condition that is applied in any recursive function is known as base condition.
(iii) A base condition is must in every recursive function otherwise it will continue to execute like an infinite loop.
8.
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.
9.
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.
10.
(i) Functions are named blocks of code that are designed to do specific job.
(ii) If you need to perform that task multiple times throughout your program, you just call the function dedicated to handling that task.
11.
| S.No | Function | Description | Syntax | Example |
| (i) | min () | Returns the minimum value in a list. | min (list) | MyList = [21,76,98,23] print ('Minimum of MyList :', min (MyList)) Output: Minimum of MyList : 21 |
| (ii) | max () | Returns the maximum value in a list. | max (list) | MyList = [21,76,98,23] print ('Maximum of MyList :', max(MyList)) Output: Maximum of Mylist :98 |
| (iii) | sum () | Returns the sum of values in a list. | sum (list) | MyList = [21,76,98,23] print ('Sum of MyList :', sum (MyList)) Output: Sum of MyList: 218 |
12.
The global keyword are used modify the global variable inside the function.
Changing Global Variable From Inside a Function using global keyword.
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
13.
(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
14.
(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
15.
Advantages of User-defined Functions
(i) Functions help us to divide a program into modules. This makes the code easier to manage.
(ii) It implements code reuse. Every time you need to execute a sequence of statements, all you need to do is to call the function.
(iii) Functions, allows us to change functionality easily, and different programmers can work on different functions.
16.
(i) When you want to perform a particular task that you have defined in a function, you call the name of the function responsible for it.
(ii) If you need to perform that task multiple times throughout your program, you don't need to type all the code for the same task again and again.
(iii) You just call the function dedicated to handling that task, and the call tells Python to run the code inside the function.
17.
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.
18.
(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.
19.
(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.
20.
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
21.
# 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))
22.
# 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))
23.
(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
24.
(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
25.
| 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 |
26.
Scope of variable refers to the part of the program, where it is accessible, i.e., area where the variables refer (use). The scope holds the current set of variables and their values. The two types of scopes-local scope and global scope.
Local Scope: A variable declared inside the function's body is known as local variable.
Rules of local variable:
(i) A variable with local scope can be accessed only within the function 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.
(v) Example: Create a Local Variable
def loc():
y=0 # local scope
print(y)
loc()
Output:
0
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.
Rules of global Keyword:
The basic rules for global keyword in Python are:
(i) When we define a variable outside a function, it's global by default. You don't have to use global keyword.
(li) We use global keyword to modify the value of the global variable inside a function.
(iii) Use of global keyword outside a function has no effect.
Example: Accessing global Variable From Inside a Function
c = 1 # global variable
def add():
print(c)
add()
Output:
1
27.
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
28.
(b)
floor ()
29.
(a)
Recursion
30.
(b)
Recursion
31.
(c)
chr ()
32.
(a)
global
33.
(b)
Keyword
34.
(c)
format
35.
(b)
scope
36.
(d)
Keywords
37.
(c)
1000
38.
(a)
keyword
39.
(c)
Print ()
40.
(b)
Identification
41.
(c)
Return
42.
(b)
Recursive
12th Standard Syllabus & Materials
12th Standard
TN 12th Tamil அருமை உடைய செயல் - செய்யுள்-தேவாரம் Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Tamil அருமை உடைய செயல் - செய்யுள்-பெருமாள் திருமொழி Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Tamil அருமை உடைய செயல் - செய்யுள்-தெய்வமணிமாலை * Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Tamil நாகரிகம், தொழில், வணிகம், ஆளுமை - உரைநடை உலகம் -திரைமொழி 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