Mini Project
Mini Project
IN PYTHON
Submitted By:
Gujjula Divya
22J41A0521
Computer Science and Engineering
INTRODUCTION:
A function is a block of program statements which can be used repetitively in a
program. It saves the time of a developer. There are some built-in functions which part of
python.
➢ User-defined functions:
user-defined functions are those that users create to perform specific tasks. These
functions are defined using the ‘def’ keyword followed by the function name and
parentheses ‘()’.
EXAMPLE:
def greet(name):
return f"Hello, {name}!"
RETURN STATEMENT:
Functions can return values using the `return` statement.
ADVANCED TOPICS:
➢ Recursive Functions:
Functions that call themselves are known as recursive functions.
def factorial(n):
if n == 0 or n == 1:
return 1
else:
return n * factorial(n-1)
➢ Lambda Functions:
Lambda functions are small anonymous functions.
square = lambda x: x ** 2
CONCLUSION:
User-defined functions are crucial for writing efficient and modular code. They help in
breaking down complex problems into smaller, manageable tasks.