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: 04/09/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.
Which of the following keyword is used to define the function testpython(): ?
define
pass
def
while
2.
Pick the correct one to execute the given statement successfully.
if ____ : print(x, " is a leap year")
x%2=0
x%4==0
x/4=0
x%4=0
3.
In which arguments the correct positional order is passed to a function?
Required
Keyword
Default
Variable-length
4.
A Function which calls itself is called as
Built-in
Recursion
Lambda
return
5.
A named blocks of code that are designed to do one specific job is called as
Loop
Branching
Function
Block
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 points to be noted while defining a function?
10.
How recursive function works?
11.
What is composition in functions?
12.
Explain recursive function with an example.
13.
Write a Python code to find the L.C.M. of two numbers.
1.
(c)
def
2.
(b)
x%4==0
3.
(a)
Required
4.
(b)
Recursion
5.
(c)
Function
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.
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.
10.
(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.
11.
(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.
12.
(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
13.
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
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