Class 10 - Function - Part I
Class 10 - Function - Part I
དཔལ་ལྡན་འབྲུག་གཞུང་།
ཤེས་རིག་དང་རིག་རྩལ་གོང་འཕེལ་ལྷན་ཁག།
Department of School Education
Ministry of Education & Skills Development
Python Coding
Class X ICT Curriculum
January 2024
Key Concept # 3
FUNCTIONS
Part I
Concept Overview
Main concepts Sub - concepts
● Definition of function
● Purpose of function
Function ● Types of function (built-in,User-defined)
● Creating a function
● Calling a function
○ Calling function without parameter, Calling
function with parameter(s)
● Understanding function through Turtle module
Objectives
● Define a function in Python programming.
● Recognize the benefits of using functions, such as code reuse and
modular design.
● Write the correct syntax for declaring functions in Python.
● Identify the key components of a function declaration, including the
function name, parameters, and the optional return statement.
● Differentiate between parameter and argument in a function.
● Create functions that handle multiple arguments to solve coding problem.
● Create drawings or shapes in Turtle module using functions.
Understanding Functions
● Functions are blocks of reusable code that perform a specific task
whenever it is called.
● Functions should be given a meaningful name to make it more
readable.
● A function returns data as a result by using the return statement within
its body.
● A function is called by writing its name with the appropriate arguments.
Syntax Code
def function_name(): 1 def greet():
function body 2 print(“Hello World!”)
function_name()#function called 3 greet()#function called
January 2024 © ICT Curriculum, MoESD
PYTHON Key stage IV Class X
Importance of Function
Given below is some function importance in Python program.
Types of Functions
● Built-in functions are part of the Python standard library.
They are available for use without the need to create
Built-in separately.
1
Functions ● Examples:
len(),print(),input(),range(),max(),min(),
sum()
Code Code
1 name = “Pema Wangchuk” 1 for x in range(1,5):
2 count = len(name) 2 total + = x
3 print(“Total Char:”,count) 3 print(“Total:”, total)
Output Output
Total Char: 13 Total:10
ACTIVITIES
1 2
Non-parameterized Function Parameterized Function
A function that doesn't have any Function that has one or more
parameters as an input. parameters as an input.
syntax syntax
Examples
1 2
Non-parameterized Function Parameterized Function
Output Output
5 5
Understanding Functions
Key word
Which of the following option given below is the correct way to define a
function that will multiply two numbers?
A B C D
Calling a Function
After defining a function, we need to call the function to use it. Function name
followed by parenthesis is used to call the function as given below.
Code Code
1 def add(x,y): 1 def add(a,b):
2 print(“Sum:”,x+y) 2 print(“Sum:”,a+b)
3 #Function not called 3 #Function called
4 4 add(5,9)
5 5 add(10,12)
Output Output
Sum: 14
Empty
Sum: 22
January 2024 © ICT Curriculum, MoESD
PYTHON Key stage IV Class X
Code Output
Code
Output
sum of 3 and 4 is 7
Output
Enter value length: 2
Enter value breadth:3
area = 6.0 unit square
January 2024 © ICT Curriculum, MoESD
PYTHON Key stage IV Class X
Code Output
Code Output
Code Output
1 def first_five_even_number(): 2
2 for num in range(2,11): 4
3 if num%2==0: 6
4 print(num) 8
5 first_five_number() 10
Code
1 from turtle import *
2 title(“Drawing circles”)
3 def draw_circle():
4 pendown()
5 circle(50)
6 penup()
7 draw_circle()
8 goto(50,-100)
9 draw_circle()
Code
1 from turtle import *
2 title(“Drawing Hexagon”)
3 def draw_hexagon():
4 for i in range(6):
5 forward(100)
6 left(60)
7 draw_hexagon()
Key
Points
● Function is a block of reusable code that performs a specific task.
● Using functions in programs help in code readability, reusability and
debugging.
● Functions are defined using the def keyword followed by function name
and parenthesis.
● There are two ways of defining a function - parameterized and
non-parameterized.
● Arguments are values assigned to parameters and they are used when
calling a function.
● Functions can be used to solve different types of problems including
drawing shapes using Turtle module.
January 2024 © ICT Curriculum, MoESD
PYTHON Key stage IV Class X
བཀྲིན་ཆེ།
THANK YOU