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: 12/08/2019
Python Functions
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.
print (ord('A') displays
65
A
a
97
2.
How many types of scopes in Python?
3
4
2
many
3.
Which function is mostly used for creating small and one time anonymous function?
Synchronous
Lambda
User-defined
Built-in
4.
Which of the following is used to define variable-length arguments?
*
$
#
//
5.
What will be the output if the return has no argument?
No
Return
None
End
6.
Which of the following provides better modularity for your python application
function
tuples
dictionaries
control structures
7.
Which of the following avoids repetition and makes high degree of code reusing?
Loop
Branching
Functions
Dictionaries
8.
Which of the following keyword is used to define the function testpython(): ?
define
pass
def
while
9.
In which arguments the correct positional order is passed to a function?
Required
Keyword
Default
Variable-length
10.
A named blocks of code that are designed to do one specific job is called as
Loop
Branching
Function
Block
11.
Write the output for the following program.
12.
How the nested block are indented?
13.
How the statements in a black are written in python?
14.
How to set the limit for recursive function? Give an example.
15.
What is function?
16.
Write the advantages of user-defined functions.
17.
When do you call the function to perform a specify task?
18.
What are the points to be noted while defining a function?
19.
How recursive function works?
20.
What is composition in functions?
21.
Write a python program to find Fibonacci series of n terms using recursion.
22.
Explain different types arguments used in python with an example.
23.
Explain recursive function with an example.
1.
(a)
65
2.
(c)
2
3.
(b)
Lambda
4.
(a)
*
5.
(c)
None
6.
(a)
function
7.
(c)
Functions
8.
(c)
def
9.
(a)
Required
10.
(c)
Function
11.
z = lamda x, y:x//y
print (z (10, 3))
Output: 3
12.
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.
13.
In Python, statements in a block are written with indentation.
14.
(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))
15.
(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.
16.
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.
17.
(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.
18.
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.
19.
(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.
20.
(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.
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.
(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
23.
(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
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