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: 05/09/2022
QB365 provides a detailed and simple solution for every Possible Book Back Questions in Class 12 Computer Science Subject - Python Functions , English Medium. It will help Students to get more practice questions, Students can Practice these question papers in addition to score best marks.
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.
Explain recursive function with an example.
2.
Write a Python code to find the L.C.M. of two numbers.
3.
Explain the following built-in functions.
(a) id ()
(b) chr ()
(c) round ()
(d) type ()
(e) pow ()
4.
Explain the scope of variables with an example.
5.
Explain the different types of function with an example.
1.
(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
2.
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
3.
| 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 |
4.
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
5.
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