1 / 8

STRING MANUPILATION

Learn about the different types of string operators in Python, including basic operators like concatenation and replication, membership operators like in and not in, and comparison operators. Examples and explanations provided.

jessicau
Télécharger la présentation

STRING MANUPILATION

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. STRING MANUPILATION

  2.    STRING OPERATORS TYPES OF STRING OPERATORS:- • BASIC OPERATORS • MEMBERSHIP OPERATORS • COMPARISON OPERATORS

  3. 1. BASIC OPERATORS THE TWO BASIC OPERATORS OF STRING ARE:- + AND *. YOU HAVE USED THESE ARITHMETRIC OPERATORS BEFORE FOR ADDITION AND MULTIPLICATION RESPECTIVELY. BUT WHEN USED WITH STRINGS, + OPERATOR PERFORMS CONCATENATION RATHER THAN ADDITION AND*OPERATOR PERFORMS REPLICATION RATHER THAN MULTIPLICATION. EXAMPLES:- • CONCATENATION:- str1 = 'Hello' str2 ='World!' print('str1 + str2 = ', str1 + str2) • REPLICATION:- str1 = 'Hello' str2 ='World!' print('str1 * 3 =', str1 * 3)

  4. 2. MEMBERSHIP OPERATORS THERE ARE TWO MEMBERSHIP OPERATORS FOR STRING .THESE ARE INAND NOT IN. • IN:- RETURNS TRUE IF A CHARACTER OR A SUBSTRING EXISTS IN THE GIVEN STRING; FALSE OTHERWISE.                          EX:- "A" in "HEYA"                                # RETURN TRUE • NOT IN:- RETURNS TRUEIF A CHARACTER OR A SUBSTRING DOES NOT EXIST IN THE GIVEN STRING; FALSE OTHERWISE.                          EX:- "jap" not in "JAPAN"                                # RETURN TRUE BECAUSE PYTHON IS CASE- SENSITIVE

  5. 3. COMPARISION OPERATORS Python string comparison is performed using the characters in both strings. The characters in both strings are compared one by one. When different characters are found then their Unicode value is compared. The character with lower Unicode value is considered to be smaller. EXAMPLES:- print(fruit1 == 'Apple')                #  TRUE print(fruit1 != 'Apple')                #  FALSE print(fruit1 < 'Apple')                 #  FALSE print(fruit1 > 'Apple')                 #  FALSE print(fruit1 <= 'Apple')               #  TRUE print(fruit1 >= 'Apple')               #  TRUE

  6. STRING FUNCTIONS

  7. THE END MADE BY:- CHETANYA SHARMA

More Related