Day 8: Methods in Python

Methods are functions attached to an object

# String is an object which has access to several methods
>>> name = "Soumil"
>>> name.upper()
>>> name.lower()
# Others include str.find(), str.join(), str.replace()

# to see all methods, simply hit Tab
>>> first_name.
first_name.capitalize()   first_name.isidentifier() first_name.rfind(
first_name.casefold()     first_name.islower()      first_name.rindex(        first_name.isnumeric()    first_name.rjust(
first_name.count(         first_name.isprintable()  first_name.rpartition(
first_name.encode(        first_name.isspace()      first_name.rsplit(
first_name.endswith(      first_name.istitle()      first_name.rstrip(
first_name.expandtabs(    first_name.isupper()      first_name.split(
first_name.find(          first_name.join(          first_name.splitlines(
first_name.format(        first_name.ljust(         first_name.startswith(
first_name.format_map(    first_name.lower()        first_name.strip(
first_name.index(         first_name.lstrip(        first_name.swapcase()
first_name.isalnum()      first_name.maketrans(     first_name.title()
first_name.isalpha()      first_name.partition(     first_name.translate(
first_name.isascii()      first_name.removeprefix(  first_name.upper()
first_name.isdecimal()    first_name.removesuffix(  first_name.zfill(
first_name.isdigit()      first_name.replace(

Complete String reference here

Method Chaining

Some methods can be chained together to produce a result

>>> greeting = "welcome"
>>> greeting.strip().upper().join(('***', '***'))

Help function in python

One of the coolest thing about Python I liked is the help utility.

>>> help()

Welcome to Python 3.10's help utility!

If this is your first time using Python, you should definitely check out
the tutorial on the internet at

Enter the name of any module, keyword, or topic to get help on writing
Python programs and using Python modules.  To quit this help utility and
return to the interpreter, just type "quit".

To get a list of available modules, keywords, symbols, or topics, type
"modules", "keywords", "symbols", or "topics".  Each module also comes
with a one-line summary of what it does; to list the modules whose name
or summary contain a given string such as "spam", type "modules spam".


Just type in available keywords and you can access documentation without needing to visit the site.

Hit q or quit to exit the utility

What’s your Reaction?

Published by Soumil Roy

I'm a Full-Stack Developer with 7+ years of experience in Web design & development .Currently building expertise in React, TypeScript & GraphQL

Leave a comment

Your email address will not be published.

Open WhatApp
Hello 👋 Click the button below connect with me.