Chapter 1: All Python String Methods

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/41

flashcard set

Earn XP

Description and Tags

Complete set of vocabulary flashcards defining built-in Python string methods for Chapter 1: All Python String.

42 Terms

1
New cards

str.capitalize()

Converts the first character of the string to uppercase and converts all remaining characters to lowercase.

2
New cards

str.casefold()

Converts the string to lowercase using an aggressive algorithm suitable for caseless matching and comparisons.

3
New cards

str.center(width, fillchar)

Returns a centered string of length equal to width, padded with the specified fillchar (default is an ASCII space).

4
New cards

str.count(sub, start, end)

Returns the number of non-overlapping occurrences of a specified substring within the optional slice range [start, end].

5
New cards

str.encode(encoding, errors)

Returns an encoded version of the string as a bytes object using the specified character encoding.

6
New cards

str.endswith(suffix, start, end)

Returns True if the string ends with the specified suffix, otherwise returns False.

7
New cards

str.expandtabs(tabsize)

Returns a copy of the string where all tab characters are replaced with one or more spaces, depending on the specified tabsize (default is 88).

8
New cards

str.find(sub, start, end)

Returns the lowest index where the substring sub is found within the string, or −1-1 if the substring is not found.

9
New cards

str.format(*args, **kwargs)

Formats the string by replacing curly brace placeholders with the specified positional or keyword arguments.

10
New cards

str.index(sub, start, end)

Similar to find(), but raises a ValueError if the specified substring is not found.

11
New cards

str.isalnum()

Returns True if all characters in the string are alphanumeric (letters or numbers) and there is at least one character.

12
New cards

str.isalpha()

Returns True if all characters in the string are alphabetic and there is at least one character.

13
New cards

str.isascii()

Returns True if the string is empty or all characters in the string are ASCII characters.

14
New cards

str.isdecimal()

Returns True if all characters in the string are decimal characters and there is at least one character.

15
New cards

str.isdigit()

Returns True if all characters in the string are digits (including superscripts and subscripts) and there is at least one character.

16
New cards

str.isidentifier()

Returns True if the string is a valid Python identifier according to language definitions.

17
New cards

str.islower()

Returns True if all cased characters in the string are lowercase and there is at least one cased character.

18
New cards

str.isnumeric()

Returns True if all characters in the string are numeric characters (such as fractions or Roman numerals) and there is at least one character.

19
New cards

str.isprintable()

Returns True if all characters in the string are printable or the string is empty.

20
New cards

str.isspace()

Returns True if all characters in the string are whitespace characters and there is at least one character.

21
New cards

str.istitle()

Returns True if the string follows title casing rules (each word starts with an uppercase character followed by lowercase characters).

22
New cards

str.isupper()

Returns True if all cased characters in the string are uppercase and there is at least one cased character.

23
New cards

str.join(iterable)

Concatenates an iterable of strings into one string using the calling string as the delimiter.

24
New cards

str.ljust(width, fillchar)

Returns a left-justified string of specified width, padded on the right with fillchar (default is an ASCII space).

25
New cards

str.lower()

Returns a copy of the string with all cased characters converted to lowercase.

26
New cards

str.lstrip(chars)

Returns a copy of the string with leading whitespace (or specified leading characters in chars) removed.

27
New cards

str.partition(sep)

Splits the string at the first occurrence of sep and returns a 3-tuple containing the part before sep, sep itself, and the part after sep.

28
New cards

str.replace(old, new, count)

Returns a copy of the string with occurrences of old replaced by new, up to the optional count limit.

29
New cards

str.rfind(sub, start, end)

Returns the highest index where the substring sub is found, or −1-1 if it is not found.

30
New cards

str.rindex(sub, start, end)

Similar to rfind(), but raises a ValueError if the specified substring is not found.

31
New cards

str.rjust(width, fillchar)

Returns a right-justified string of specified width, padded on the left with fillchar (default is an ASCII space).

32
New cards

str.rpartition(sep)

Splits the string at the last occurrence of sep and returns a 3-tuple containing the part before sep, sep itself, and the part after sep.

33
New cards

str.rsplit(sep, maxsplit)

Splits the string from the right into a list of strings using sep as the delimiter, up to maxsplit times.

34
New cards

str.rstrip(chars)

Returns a copy of the string with trailing whitespace (or specified trailing characters in chars) removed.

35
New cards

str.split(sep, maxsplit)

Splits the string from the left into a list of substrings using sep as the delimiter, up to maxsplit times.

36
New cards

str.splitlines(keepends)

Splits the string at line breaks and returns a list of lines, retaining line breaks if keepends is True.

37
New cards

str.startswith(prefix, start, end)

Returns True if the string starts with the specified prefix, otherwise returns False.

38
New cards

str.strip(chars)

Returns a copy of the string with both leading and trailing whitespace (or specified characters in chars) removed.

39
New cards

str.swapcase()

Returns a copy of the string with uppercase characters converted to lowercase and lowercase characters converted to uppercase.

40
New cards

str.title()

Returns a titlecased version of the string where words start with an uppercase character and remaining characters are lowercase.

41
New cards

str.upper()

Returns a copy of the string with all cased characters converted to uppercase.

42
New cards

str.zfill(width)

Pads the string with ASCII '0' digits on the left until it reaches the specified width; correctly handles an initial sign prefix.