1/31
CSCE 1035
Name | Mastery | Learn | Test | Matching | Spaced |
|---|
No study sessions yet.
index
an integer matching a specific position in a string’s sequence of characters
slice notation
the form is my_str[start:end] and it creates a new string whose value contains the characters of my_str from indices start to end
stride
determines how much to increment the index after reading each element
field width
defines the minimum number of characters that must be inserted into the string
alignment character
determines how a value should be aligned within the width of the field
fill character
used to pad a replacement field when the inserted string is smaller than the field width
precision
indicates how many digits should be included in the output of floating types
replace(old, new)
returns a copy of the string with all occurrences of the substring old replaced by the string new; old and new arguments may be string variables/literals
replace(old, new, count)
same as replace(old, new), but it only replaces the first count occurrences of old
find(x)
returns the index of the first occurrence of item x in string or returns -1; x may be a string variable/literal
find(x, start)
same as find(x), but it begins the search at index start
find(x, start, end)
same as find(x, start), but stops the search at index at end -1
rfind(x)
same as find(x), but it searches the string in reverse, returning the last occurrence in the string
count(x)
returns the number of times x occurs in the string
ASCII table
provides a quick lookup of ASCII values
isalnum()
returns True if all characters in string are lowercase/uppercase letters or the numbers 0-9
isdigit()
return True if all characters are the numbers 0-9
islower()
returns True if all cased characters are lowercase letters
isupper()
returns True if all cased characters are uppercase letters
isspace()
returns True if all characters are whitespace
startswith(x)
returns True if the string starts with x
endswith(x)
returns True if the string ends with x
capitalize()
returns a copy of the string with the first character capitalized and the rest lowercased
lower()
returns a copy of the string with all characters lowercased
upper()
returns a copy of the string with all characters uppercased
strip()
returns a copy of the string with leading and trailing whitespace removed
title()
returns a copy of the string as a title, with first letters of words capitalized
split()
splits a string into a list of tokens
token
a substring that forms a part of a larger string
separator
a character/sequence of characters that indicates where to split the string into tokens
join()
joins a list of strings together to create a single string