Flashcards
String & List Manipulation (Gaddis Ch. 7-8)
Cards in this deck (33)
- 1methodself-operating function (performs an action on the list itself)
- 2append method'list.append(item)'
Adds an item to the end of a list - 3index method'list.index(item)'
Returns the index of the first element that shows up containing 'item' - 4insert method'insert(index, item)'
Inserts an item at the given index - 5sort method'list.sort()'
Sorts the given list from smallest to largest - 6remove method'list.remove(item)'
Removes a given item from a list - 7reverse method'list.reverse()'
Reverses the order of items in a list - 8operatorManipulates its operand(s)
- 9in operator'item in list'
Returns 'True' if the item is in the list and 'False' if it is not - 10del operator'del list[index]'
Deletes whatever is at the given index of the given list - 11functionPerforms an arbitrary operation on the supplied argument
- 12min function'min(list)'
Built-in Python function that returns the smallest value in a list - 13max function'max(list)'
Built-in Python function that returns the largest value in a list - 14len function'len(argument)'
Returns the length of a string or list - 15isalnum()Returns 'True' if the string contains letters and numbers and is at least one character long
- 16isalpha()Returns 'True' if the string only contains letters and is at least one character long
- 17isdigit()Returns 'True' if the string only contains numbers and is at least one character long
- 18islower()Returns 'True' if all of the letters in the string are lowercase and there is at least one letter in the string
- 19isupper()Returns 'True' if all of the letters in the string are uppercase and there is at least one letter in the string
- 20isspace()Returns 'True' if all of the characters in the string are whitespace characters (which include \n and \t)
- 21lower()Returns a copy of the string with all characters converted to lowercase (all non-letter characters remain unchanged)
- 22upper()Returns a copy of the string with all characters converted to uppercase (all non-letter characters remain unchanged)
- 23lstrip()Returns a copy of the string with all leading whitespace characters removed (which includes \n and \t)
- 24lstrip(char)Returns a copy of the string with all instances of 'char' that appear at the beginning of the string removed
- 25rstrip()Returns a copy of the string with all trailing whitespace characters removed (which includes \n and \t)
- 26rstrip(char)Returns a copy of the string with all instances of 'char' that appear at the end of the string removed
- 27strip()Returns a copy of the string with all leading and trailing whitespace characters removed (which includes \n and \t)
- 28strip(char)Returns a copy of the string with all instances of 'char' that appear at the beginning and end of the string removed
- 29endswith(substring)Returns 'True' if the string ends with that substring
- 30startswith(substring)Returns 'True' if the string starts with that substring
- 31find(substring)Searches for 'substring' within the string. If it is found in the string, it returns the lowest index. If not, it returns -1
- 32replace(substring, new_string)Returns a copy of the string where every instance of 'substring' is replaced by 'new_string'
- 33split methodReturns a list containing the words in the string
Information
- Description
- Misc. Flashcards on String & List Manipulation (Gaddis Ch. 7-8), created by Naomi j Steplight on 08/02/2018.
- Created by
- Naomi j Steplight
- Views
- 1
- Rating