Python Functions

Functions are used to make certain portions of codes reusable and are a great tool to bring efficiency in the codes. In Python, we define a function using keyword “def” followed by the name of the function, the parameters and the indented block which will execute the function to produce a certain output. Let’s look at few examples-

Function # 1 is called “hello” and it takes no parameter and will print “This is my first python function and I’m so excited”, whenever this function is called [ hello ()]. Functions may be given parameters and default values, in case the user is not providing or overwriting the default values, the function will use these values to process the codes.

Can you figure out what the other two Python functions are doing?

Python also has a host of in built functions – Inbuilt Functions

python_function_1

python_function_2

Cheers!

One thought on “Python Functions

  1. Pingback: Learn Python Step by Step | RP's Blog on data science

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s