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: 06/01/2020
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 statement exits a function?
Exit
Def
Return
None of these
2.
Which of the following provides better modularity for your python application
function
tuples
dictionaries
control structures
3.
Which of the following keyword is used to define the function testpython(): ?
define
pass
def
while
4.
In which arguments the correct positional order is passed to a function?
Required
Keyword
Default
Variable-length
5.
While defining a function which of the following symbol is used.
; (semicolon)
. (dot)
: (colon)
$ (dollar)
6.
What are called tuples?
7.
What are arguments? What are the types?
8.
How to set the limit for recursive function? Give an example.
9.
Define global scope.
10.
What is function?
11.
Write a note on format () with an example.
12.
When the variable - length arguments are used? Explain with an example.
13.
How recursive function works?
14.
15.
Write the rules of local variable.
16.
Write a python program to find Fibonacci series of n terms using recursion.
17.
Write a python program to find HCF of two numbers using recursion.
18.
Explain recursive function with an example.
19.
Write a Python code to find the L.C.M. of two numbers.
1.
(c)
Return
2.
(a)
function
3.
(c)
def
4.
(a)
Required
5.
(c)
: (colon)
6.
Non-keyword variable arguments are called tuples.
7.
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.
8.
(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))
9.
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.
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.
| format () | Returns the output based on the given format. 1. Binary format. Outputs the number in base 2. 2. Octal format. Outputs the number in base 8. 3. Fixed-point notation. Displays the number as a fixed-point number. The default precision is 6. |
format (value [, format_spec]) | x=14 y=25 print ('x value in binary :',format(x,'b')) print ('y value in octal :',format(y,'o')) print('y value in Fixed-point no ',format(y,'f')) Output: x value in binary: 1110 y value in octal: 31 y value in Fixed-point no: 25.000000 |
12.
(i) Syntax - Variable-Length Arguments:
def function_name(*args):
function_body
return_statement
(ii) Example:
def printnos (*nos):
for n in nos:
print(n)
return
# now invoking theprintnos() 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
13.
(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.
14.
15.
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.
16.
# 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))
17.
# 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))
18.
(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
19.
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