Function in python by R4R Team

You use functions in programming to bundle a set of instructions that you want to use repeatedly.That means that a function is a piece of code written to carry out a specified task.

There are three type of Function in python -
- Build -In function such as print(),input(),min() etc.
- User defined function
- Anonymous functions, which are also called lambda functions
So for create user defined function , in C language to make a function we need to declare the type of function, but in python we have only one keyword for create the function which is 'def'

Syntax :-
def functionname():
body

Program-

def hii():
print("Hii")

def hello():
print("Hello")

def value(a):
print(a)

hii()
hello()
value(3)
value("Pass")


output -

Hii
Hello
3
Pass


In this program, there are three function, 'hii()', 'hello()' and 'value(a)' , first two function are normal they print hii hello, while third function require parameter to pass , so at the time of calling we pass value in it so it can save in 'a' and then we print(a)



Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!