0% found this document useful (0 votes)
33 views2 pages

Python Notes

The document explains the components of defining a function in Python, including the use of the 'def' keyword, function name, parameters, and the function body. It describes how to execute a function and what happens when it reaches a return statement. An example function 'make_symbols' is provided to illustrate these concepts.

Uploaded by

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

Python Notes

The document explains the components of defining a function in Python, including the use of the 'def' keyword, function name, parameters, and the function body. It describes how to execute a function and what happens when it reaches a return statement. An example function 'make_symbols' is provided to illustrate these concepts.

Uploaded by

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

 def: The def keyword tells Python we are defining a new function.

 Function name: The word we will use to call the function. A good
function name helps explain what the function does!

 Round brackets (): Go after the function name.

 Parameters: Say what information (arguments) the function will


require to do its job. This function expects one argument - a number
to square. Parameters go inside the round brackets.

 Colon: The def line ends with: (a colon).

 Function body: The code that will run when the function is called.
We can put any code we like inside the body of a function. The body
needs to be indented (just like an if statement).

 return: Stops the function and says what information the function
should return to the code that called it.

When Python reaches a function call in our code, it will run (or execute)
that function.

Once the function finishes (stops executing), Python will return to the
place in the code where the function was called, and continue running the
code from there, as usual.

Python will stop executing the function when it reaches the end of the
function, or when it reaches a return in the function.
def make_symbols(symbol, thing, number):

make_symbols = (symbol+thing) * number

return make_symbols

print(make_symbols('#', '&', 100000))

You might also like