0% found this document useful (0 votes)
42 views3 pages

Functions: Define Code Which Is Executed Later (And Possibly Multiple Times)

Functions allow code to be defined and then executed later or multiple times. Functions can receive arguments, return values, use default arguments, and accept keyword arguments. Functions define reusable blocks of code that perform tasks and can be called from different parts of a program.

Uploaded by

Animesh Dubey
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views3 pages

Functions: Define Code Which Is Executed Later (And Possibly Multiple Times)

Functions allow code to be defined and then executed later or multiple times. Functions can receive arguments, return values, use default arguments, and accept keyword arguments. Functions define reusable blocks of code that perform tasks and can be called from different parts of a program.

Uploaded by

Animesh Dubey
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Functions

Define Code which is executed Later (and possibly Multiple Times)

def greet():
print('Hello')

greet()
greet()

Can receive Arguments

def greet(name):
print('Hello ' + name)

greet('Max')
Functions

Can return Values

def sum(a, b):


return a + b

print(sum(2, 5))

Default Arguments

def greet(name, age=29):


print('Hello ' + name + ', I am ' + age)

greet('Max')
Functions

Keyword Arguments (kwargs)

def greet(name, age):


print('Hello ' + name + ', I am' + age)

greet(age=29, name='Max')

You might also like