Back
  • Qissba
  • Courses

      CBSE Class 12

      PYTHON

      Computer Science

      • Python
      • Computer System Overview
      • Computer Networks
      • society Law & Ethics
      • Data Representation
      • Boolean Logics
      Python Online Free Courses for Classes 11th and 12th
  • Blog
  • Shop
    • Cart
    • Checkout
    • My account
  • About Us
  • Contact
  • Career
Have any question?
(+91) 09897990175
qissba@gmail.com
RegisterLogin
Qissba
  • Qissba
  • Courses

      CBSE Class 12

      PYTHON

      Computer Science

      • Python
      • Computer System Overview
      • Computer Networks
      • society Law & Ethics
      • Data Representation
      • Boolean Logics
      Python Online Free Courses for Classes 11th and 12th
  • Blog
  • Shop
    • Cart
    • Checkout
    • My account
  • About Us
  • Contact
  • Career

    Computer Science

    string-methods-python

    String Methods in Python | CBSE – Class 12

    • Posted by Kabeer Sahib
    • Categories Computer Science

    In this section, “Python String Methods: A Beginner’s Guide”, we will provide a comprehensive introduction to python String method, including

    Table of Contents

    Toggle
    • Introduction:
    • What are String Methods?
    • List of built-In string methods:
    • Built-in methods that you can use on strings.
    • Commonly Used String Methods:
    • Examples of String Methods:
    • Tips and Tricks for Working with Python Strings:
    • Conclusion:
    • What are String Methods in python?.
    • Commonly Used String Methods.
    • Examples of String Methods in Python.
    • Tips and Tricks for Working with Python Strings.
    • Built-in methods that you can use on strings.

    And, by the end of this tutorial, readers will have a solid understanding of A number of built-in methods of string in Python and will be able to use this knowledge in their own programming projects.

    Also this tutorial covers all necessary topics/concepts required to complete your exams preparations in CBSE schools / classes.

    Introduction:

    Strings are one of the most important data types in Python. They are used to store textual data and can be manipulated in various ways using string methods.

    In this beginner’s guide, we’ll explore some of the most commonly used Python string methods and how to use them.

    What are String Methods?

    Python string methods are built-in functions that can be used to manipulate strings. They provide an easy and efficient way to perform common string operations, such as changing the case of a string, replacing characters, or searching for specific substrings.

    List of built-In string methods:

    list-of-built-In-python-string-methods

    Built-in methods that you can use on strings.

    S.NMETHODDESCRIPTION
    1capitalize():Converts the first character to upper case
    2casefold()Converts string into lower case
    3center()Returns a centered string
    4count()Returns the number of times a specified value occurs in a string
    5encode()Returns an encoded version of the string
    6endswith()Returns true if the string ends with the specified value
    7expandtabs()Sets the tab size of the string
    8join()Converts the elements of an iterable into a string
    9ljust()Returns a left justified version of the string
    10lower()Converts a string into lower case
    11lstrip()Returns a left trim version of the string
    12maketrans()Returns a translation table to be used in translations
    13partition()Returns a tuple where the string is parted into three parts
    14replace()Returns a string where a specified value is replaced with a specified value
    15rfind()Searches the string for a specified value and returns the last position of where it was found
    16rindex()Searches the string for a specified value and returns the last position of where it was found
    17rjust()Returns a right justified version of the string
    18rpartition()Returns a tuple where the string is parted into three parts
    19rsplit()Splits the string at the specified separator, and returns a list
    20rstrip()Returns a right trim version of the string
    21split()Splits the string at the specified separator, and returns a list
    22splitlines()Splits the string at line breaks and returns a list
    23startswith()Returns true if the string starts with the specified value
    24strip() Returns a trimmed version of the string
    25swapcase()Swaps cases, lower case becomes upper case and vice versa
    26title()Converts the first character of each word to upper case
    27translate()Returns a translated string
    28isalnum()Returns True if all characters in the string are alphanumeric
    29isalpha()Returns True if all characters in the string are in the alphabet
    30isascii()Returns True if all characters in the string are ascii characters
    31isdecimal()Returns True if all characters in the string are decimals
    32isdigit()Returns True if all characters in the string are digits
    33isidentifier()Returns True if the string is an identifier
    34islower()Returns True if all characters in the string are lower case
    35isnumeric()Returns True if all characters in the string are numeric
    36isprintable()Returns True if all characters in the string are printable
    37isupper()Returns True if all characters in the string are upper case
    38istitle()Returns True if the string follows the rules of a title
    39isspace()Returns True if all characters in the string are whitespaces
    40index()Searches the string for a specified value and returns the position of where it was found
    41format_map()Formats specified values in a string
    42format()Formats specified values in a string
    43find()Searches the string for a specified value and returns the position of where it was found
    44upper()Converts a string into upper case
    45zfill()Fills the string with a specified number of 0 values at the beginning

    Commonly Used String Methods:

    There are many Python string methods available, but here are some of the most commonly used:

    • .lower(): Converts all the characters in a string to lowercase.
    • .upper(): This method converts all the characters in a string to uppercase.
    • .replace(): Replaces a substring with another substring in a string.
    • .split(): Method splits a string into a list of substrings based on a delimiter.
    • .startswith(): Method checks if a string starts with a given substring.
    • .endswith(): Checks if a string ends with a given substring.
    • .strip(): This method removes leading and trailing whitespace characters from a string.

    Examples of String Methods:

    Let’s take a look at some examples of how to use these methods or built-n functions.

    Example 1: Using .lower() and .upper()

    my_string = "Hello World"
    print(my_string.lower())
    print(my_string.upper())

    Output:

    hello world

    HELLO WORLD

    Example 2: Using .replace()

    my_string = "Python is fun"
    print(my_string.replace("fun", "awesome"))

    Output:

    Python is awesome

    Example 3: Using .split()

    my_string = "apple, banana, cherry"
    print(my_string.split(", "))

    Output:

    [‘apple’, ‘banana’, ‘cherry’]

    Tips and Tricks for Working with Python Strings:

    Here are some tips and tricks to help you work more efficiently with Python strings:

    • Use string formatting to insert variables into a string.
    • and use string slicing to extract substrings from a string.
    • Also use regular expressions for more complex string operations.

    Conclusion:

    In this beginner’s guide, we’ve covered some of the most commonly used string methods and how to use them. By mastering these methods, you’ll be able to manipulate strings in various ways and perform common string operations.

    Remember to practice and experiment with these methods to become proficient in using them. Happy coding!

    • Share:
    Kabeer Sahib

    A Trained Post Graduate Teacher with 10 years of experience and working as TGT/PGT–Computer Science including good Management and administration skills with managerial positions in previous work environments

    Previous post

    Python String Basics: An Introduction | CBSE - Class 12
    14 April 2023

    Next post

    Types of Strings in Python | CBSE - Class 12
    14 April 2023

    You may also like

    Operator Precedence & Associativity in Python | CBSE Class 11| Computer Science
    24 June 2025

    Dear Class 11th STUDENTS, ! Welcome to this tutorial of Operators in Python from your CBSE class 11 of …

    basics-of-python-programming-languages-cbse-class-11
    Basics of Python Programming Language | CBSE Class 11| Computer Science
    3 June 2025
    encoding-schemes-cbse-class-11-computer-science
    Encoding Schemes | ASCII | ISCII | Unicode | CBSE Class 11| Computer Science
    21 May 2025

    Leave A Reply Cancel reply

    You must be logged in to post a comment.

    Search

    Categories

    • Computer Science
    • Education
    • Education News
    Computer Science : Python – CBSE Class 11

    Computer Science : Python – CBSE Class 11

    ₹1,999.00Free
    Computer Science : System Overview – CBSE Class 11

    Computer Science : System Overview – CBSE Class 11

    ₹999.00Free
    Computer Science : Python – CBSE Class 12

    Computer Science : Python – CBSE Class 12

    ₹1,999.00Free

    Login with your site account

    Lost your password?

    Not a member yet? Register now

    Log in

    Copyright @ 2021 ! QISSBA EDUCATION ! .

    • Privacy
    • Terms
    • Sitemap
    • About Us

    Login with your site account

    Lost your password?

    Not a member yet? Register now

    Register a new account

    Are you a member? Login now