Bookmark and Share

Front Back
double quote (used inside of a double quoted string)
literal backslash (a backslash will appear in the string)
null terminator
carriage return
horizontal tab
vertical tab
If the second index in a slice is less than or equal to the first index, the result will always be...
an empty string
separate 2 subscripts with a colon
the piece of the string that's extracted will start at the first index and continue to one character before the last index
extract one or more characters from a string
obtains the numbrer of characters in a string
converts a number to a string
repetition operator
concatanation operator  
raw string
escape character
single quote (used inside a single quoted string)
One of the most common uses for a string slice is...
to remove the newline that is present on text read from a file
use the in operator to...
determine whether a particular character or string occurs in a string
A function is simply a way to eliminate repeated code. When a function is applied to an object, it is no longer a function but is known as a...
A function is simply...
a way to eliminate repeated code
To invoke a method...
provide the name of the object the method is to act upon, followed by a period, finally followed by the method name and the parenthesized list of additional arguments
To call a function...
pass the arguments in a comma-separated list surrounded by parentheses after the function name.
If the method does not take any arguments...
provide empty parentheses
split method
breaking a line of text apart into words or tokens
the join method
combining several of those pieces into a single character string
find and rfind
return the location of the substring if found and -1 if the substring is not found
index an rindex
return the location of the substring if found and raise a ValueError exception otherwise
start and end
limit the search for substrings to just the part of a string on which the method is invoked
methods that begin with the letter r
return the highest index at which the substring was found, while the other methods return the lowest index
centerljust, and rjust
take a single argument that specifies the length of the output string within which to center, left-justify, or right-justify, respectively, the string upon which the method is being invoked
lstrip and rstrip methods
return a string that is like the one upon which the method is invoked but without any leading (lstrip) or trailing (rstrip) whitespace; the strip method removes both leading and trailing whitespace
the capitalize method
returns a string whose first character is uppercase, while all the remaining characters are lowercase
the title method
capitalizes each word in the string upon which it's invoked
the capitalizelowerswapcasetitle, and upper methods
create strings with modified cases
predicate method
take no arguments and return 1 if all the characters in a string are of a particular type -- 0 otherwise
Alphanumeric (alphabetic or digit)
Digit (0 through 9)
Whitespace characters (space, tab, newline, etc.)
Python supports three types of numeric data:
  • floating-point numbers
  • integers
  • complex numbers
Python uses the letter j (or J) following a number to...
represent the imaginary part of a complex number
You can convert from one type of number to another using...
the functions int()float() or complex()
converts an integer to a float
x of y cards Next >|