Functions in Programming Information Communication Technology
Functions in Programming Information Communication Technology
FUNCTIONS IN
PROGRAMMIN
G
Abdullah Saleh Waqas Khushi Zain
WHAT IS A
FUNCTION?
Examples:
• print(): Used to output text or variables to the
console. Example: print("Hello, World!")
2. USER-DEFINED
FUNCTIONS
User-defined functions are functions that
programmers create to perform specific tasks not
covered by predefined functions. They’re especially
useful for organizing code, breaking down complex
problems, and reusing code across different parts
of a program.
Examples:
• Imagine you frequently need to calculate the
area of a rectangle. Instead of repeatedly
writing the formula, you could create a user-
defined function
COMPARISON
Definition Definition
Predefined functions are built-in functions in a programming User-defined functions are custom functions created by
language that you can use directly without writing any extra programmers to perform specific tasks, making code more
code. Simply call the function to perform its task, like print() to organized, reusable, and suited to unique needs.
display text or len() to find the length of a string.
Examples Examples
Flexibility Flexibility
Ready to use; just call the function Requires defining the function before use
USING
PREDEFINED
FUNCTIONS
How to Use Them:
• Simply call the function by its name, followed by parentheses containing any
required arguments.
Examples:
• print("Hello, World!") – Displays the text "Hello, World!" on the screen.
}
}
DEFINING FUNCTIONS CALLING FUNCTIONS
EXAMPLE:
greet("Alice")
KEY COMPETITIVE
ADVANTAGES
Value-Returning Functions:
• Return a value that can be used in
other parts of the program.
• Often used for calculations or data
processing.
COMSATS SAHIWAL
THANK
YOU
for your time and attention