PYTHON PROGRAMMING FOR BEGINNERS by Reed Mark

PYTHON PROGRAMMING FOR BEGINNERS by Reed Mark

Author:Reed, Mark
Language: eng
Format: epub
Published: 2022-06-11T00:00:00+00:00


String Methods

Python has built-in functions or methods that work well with strings. The string method runs ‘on’ an object. If a created variable is a string, then the lower () or upper() functions run on the string object and return the results. The concept of running methods on objects is why Python is considered an object oriented programming language.

Some of these string methods include:

● Strip() which is used to eliminate the white spaces from the beginning or the end of a string.

● Lower() and upper () methods returns the string in lower case and upper case respectively.

● Startswith(other) and endswith(other) methods measure the start and end of the string.

● Isalpha(), isspace(), and isdigit() are used to test whether the string characters belong to a certain class character.

● Find(other) is used to search for a particular string within the created variable and return the first index where it begins or a -1 if it’s found.

● Join(list) is used to join together elements in a given list using the string as the delimiter. For example, join(‘xxx’, ‘yyy’, ‘zzz’) -> [‘xxx’, ‘yyy’, ‘zzz’].

● Split(‘delim’) returns substring list separated by a given delimiter. Delimiter in this case acts as text and not a regular expression that is, ‘xxx,yyy,zzz.split(‘.’) –> [‘xxx’, ‘yyy’, ‘zzz’]. The split() with no arguments splits characters with white spaces.

● Replace(‘old’, ‘new’) returns a string where the old string characters are replaced with new characters.

● Format() is used to format specified values within a string.

● Count() returns the number of times a certain character occurs in the string.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.