Methods and Functions in Python

A guide to learning about the Python methods and functions in detail.

The built-in objects in Python have a variety of methods to use.

Basic methods

Discovering methods on your own

When you write “.” after the object and hit ‘tab’, you get a list of methods in the Jupyter notebook.

To get help on the method you can use “shift+tab”.

In case you don't use the Jupyter notebook, you can also use the below command.


Functions allow us to create blocks of code that can be easily executed many times without needing to constantly rewrite the entire block of code.

Function syntax (Source: Google)

“DOCSTRING” allows you to document the information about the function. So if in future anyone needs to know it’s details, one can with the aid of “help” function.

Functions can also take arguments too as shown below.

We will use the “return” keyword to send back the result of the function instead of just printing it out. “return” allows us to assign the output of the function to a new variable and therefore it is preferred over just printing.

The default name can also be given to the argument. So in case, no argument is passed while calling the function, the default name will be taken.

Function to find a particular word in a string

Notice that “‘python’ in string1.lower()” returns a boolean value itself. So we do not need to return boolean value separately.

Refer to the notebook here.

Beginner-level books to refer to learn Python:

Advance-level books to refer to learn Python:

Reach out to me: LinkedIn

Check out my other work: GitHub

Self-driven woman who wishes to deliver creative and engaging ideas and solutions in the field of technology.