3 Functions
3 Functions
- G. Anushiya Rachel
Assistant Professor, CSE
Shiv Nadar University Chennai
Function Definition
• Header
𝒅𝒆𝒇 𝒇𝒖𝒏𝒄_𝒏𝒂𝒎𝒆 𝒂𝒓𝒈𝟏, 𝒂𝒓𝒈𝟐, … 𝒂𝒓𝒈𝑵 :
• To define a function, start with the keyword 𝑑𝑒𝑓.
• This is followed by the name of function and comma separated list of
identifiers called parameters and terminated with a colon.
• Values passed to the function – arguments
• Body
• Contains the sequence of steps to be executed
• Note: A function must be defined before it is called but can be defined anywhere
in the program.
>>> hello(‘John’)
Hello John