STRING MANUPILATION.

Slides:



Advertisements
Similar presentations
Computer Science & Engineering 2111 Text Functions 1CSE 2111 Lecture-Text Functions.
Advertisements

Strings Testing for equality with strings.
CS 100: Roadmap to Computing Fall 2014 Lecture 0.
Ch 8. Characters and Strings Timothy Budd 2 Characters and Literals Strings Char in C++ is normally an 8-bit quantity, whereas in Java it is a 16-bit.
1 Python Chapter 3 Reading strings and printing. © Samuel Marateck.
CS Nov 2006 C-strings.
1.
Strings. Strings are amongst the most popular types in Python. We can create them simply by enclosing characters in quotes. Python treats single quotes.
Chapter 9 Creating Formulas that Manipulate Text Microsoft Office Excel 2003.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 9 More About Strings.
© Copyright 2012 by Pearson Education, Inc. All Rights Reserved. Chapter 8 More on Strings and Special Methods 1.
PHP Using Strings 1. Replacing substrings (replace certain parts of a document template; ex with client’s name etc) mixed str_replace (mixed $needle,
Python for Informatics: Exploring Information
An Introduction to Java Programming and Object-Oriented Application Development Chapter 7 Characters, Strings, and Formatting.
Chapter 5 Strings CSC1310 Fall Strings Stringordered storesrepresents String is an ordered collection of characters that stores and represents text-based.
Characters, Strings, And The string Class Chapter 10.
1 CSC 221: Introduction to Programming Fall 2011 Lists  lists as sequences  list operations +, *, len, indexing, slicing, for-in, in  example: dice.
String String Builder. System.String string is the alias for System.String A string is an object of class string in the System namespace representing.
File I/O CMSC 201. Overview Today we’ll be going over: String methods File I/O.
CSC 270 – Survey of Programming Languages
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 10 Characters, Strings, and the string class.
8 1 String Manipulation CGI/Perl Programming By Diane Zak.
Strings CSE 1310 – Introduction to Computers and Programming Alexandra Stefan University of Texas at Arlington 1.
LECTURE 5 Strings. STRINGS We’ve already introduced the string data type a few lectures ago. Strings are subtypes of the sequence data type. Strings are.
CSC 162 Visual Basic I Programming. String Functions LTrim( string ) –Removes leading spaces from the left side of string RTrim( string ) –Removes trailing.
Winter 2016CISC101 - Prof. McLeod1 CISC101 Reminders Quiz 3 this week – last section on Friday. Assignment 4 is posted. Data mining: –Designing functions.
G. Pullaiah College of Engineering and Technology
Regular Expressions Upsorn Praphamontripong CS 1110
C-Strings We have already seen that a C-string is a null-terminated array of characters.
Strings Chapter 6 Python for Everybody
Character Processing How characters can be treated as small integers?
Chapter 8 Text Files We have, up to now, been storing data only in the variables and data structures of programs. However, such data is not available.
Strings, StringBuilder, and Character
Module 4 String and list – String traversal and comparison with examples, List operation with example, Tuples and Dictionaries-Operations and examples.
String Processing Upsorn Praphamontripong CS 1110
String String Builder.
Lecture 5 Strings.
Standard Version of Starting Out with C++, 4th Edition
Chapter 12: Text Processing
Winter 2018 CISC101 11/16/2018 CISC101 Reminders
Chapter 12: Text Processing
Chapter 7: Strings and Characters
Object Oriented Programming
Basic Python Collective variables (sequences) Lists (arrays)
String Manipulation Part 2
Chapter 8 More on Strings and Special Methods
Chapter 8 More on Strings and Special Methods
Python - Strings.
10.1 Character Testing.
Chapter 8 More on Strings and Special Methods
CS 100: Roadmap to Computing
CS 1111 Introduction to Programming Fall 2018
Basic String Operations
Character Processing How characters can be treated as small integers?
CS 1111 Introduction to Programming Spring 2019
Standard Version of Starting Out with C++, 4th Edition
590 Scraping – NER shape features
Topics Basic String Operations String Slicing
Bryan Burlingame 13 March 2019
Introduction to Computer Science
CSE 231 Lab 3.
Introduction to Computer Science
Python Strings.
Topics Basic String Operations String Slicing
By Himanshi dixit 11th ’B’
Winter 2019 CISC101 5/17/2019 CISC101 Reminders
Boolean in C++ CSCE 121.
CS 100: Roadmap to Computing
CMPT 120 Topic: Python strings.
Topics Basic String Operations String Slicing
Presentation transcript:

STRING MANUPILATION

STRING OPERATORS TYPES OF STRING OPERATORS:- BASIC OPERATORS MEMBERSHIP OPERATORS COMPARISON OPERATORS

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:- print('str1 * 3 =', str1 * 3)

2. MEMBERSHIP OPERATORS THERE ARE TWO MEMBERSHIP OPERATORS FOR STRING .THESE ARE IN AND 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 TRUE IF 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

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

STRING FUNCTIONS Python String Functions capitalize() - Returns the string with first letter capitalized and the rest lowercased. casefold() - Returns a lowercase string, generally used for caseless matching. This is more aggressive than the lower() method. center() - Center the string within the specified width with optional fill character. count() - Count the non-overlapping occurrence of supplied substring in the string. encode() - Return the encoded version of the string as a bytes object. endswith() - Returns ture if the string ends with the supplied substring. expandtabs() - Return a string where all the tab characters are replaced by the supplied number of spaces. find() - Return the index of the first occurrence of supplied substring in the string. Return -1 if not found.

Python String Functions format() - Format the given string. format_map() - Format the given string. index() - Return the index of the first occurrence of supplied substring in the string. Raise ValueError if not found. isalnum() - Return true if the string is non-empty and all characters are alphanumeric. isalpha() - Return true if the string is non-empty and all characters are alphabetic. isdecimal() - Return true if the string is non-empty and all characters are decimal characters. isdigit() - Return true if the string is non-empty and all characters are digits. isidentifier() - Return true if the string is a valid identifier. islower() - Return true if the string has all lowercased characters and at least one is cased character. isnumeric() - Return true if the string is non-empty and all characters are numeric.

MADE BY:- CHETANYA SHARMA THE END MADE BY:- CHETANYA SHARMA