Use LEFT and RIGHT arrow keys to navigate between flashcards;
Use UP and DOWN arrow keys to flip the card;
H to show hint;
A reads text to speech;
37 Cards in this Set
- Front
- Back
Statement used to remove a list element if you know the index |
del list[index] |
|
Function used to find the number of elements in a list |
use: len([1, 2, 3]) result: 3 |
|
Operation used to concatenate multiple lists together |
use: [1, 2, 3] + [4, 5, 6] result: [1, 2, 3, 4, 5, 6] |
|
Operation used to repeat list elements |
use: ['Hi!'] * 4 result:['Hi!', 'Hi!', 'Hi!', 'Hi!'] |
|
Operation used to find whether a value is a member of a list or not |
use: 3 in [1, 2, 3] result: True |
|
Operation used to iterate through values in a list |
use: for x in [1, 2, 3]: print x result: 1 2 3 |
|
Operation to find the value at a specific index in a list |
setup: L = ['spam', 'Spam', 'SPAM!'] use: L[2] result: 'SPAM!' notes: "Offsets start at zero" |
|
Operation to find the value of a specific index, counting from the end of the list |
setup: L = ['spam', 'Spam', 'SPAM!'] use: L[-2] result: 'Spam' notes: "Negative: count from the right" |
|
Operation to fetch slices of a list, given a range of indexes |
setup: L = ['spam', 'Spam', 'SPAM!'] use: L[1:] result: ['Spam', 'SPAM!'] notes: "Slicing fetches sections" |
|
Function to compare elements of two lists |
cmp(list1, list2) |
|
Function to return the item from the list with the maximum value |
max(list) |
|
Function to return the item from the list with the minimum value |
min(list) |
|
Function to convert a tuple into a list |
list(sequence) |
|
Method to append an object to a list |
list.append(object) |
|
Method to return a count of how many times an object occurs in a list |
list.count(object) |
|
Method to append the contents of a sequence to a list |
list.extend(sequence) |
|
Method to return the lowest index in list that an object appears |
list.index(object) |
|
Inserts an object into a list at offset index |
list.insert(index, object) |
|
Method to remove and return the last object from list |
list.pop(object=list[-1]) |
|
Method to remove an object from a list |
list.remove(object) |
|
Method to reverse objects of a list in place |
list.reverse() |
|
Method to sort objects of list, using a compare function if given |
list.sort([func]) |
|
What must a dictionary key be? |
Immutable. ie: strings, numbers, tuples not: lists, other dictonaries |
|
Function to compare the elements of two dictionaries |
cmp(dictionary1, dictionary2) |
|
Function to give the total length of (number of items in) a dictionary |
len(dictionary) |
|
Function to produce a printable string representation of a dictionary |
str(dictionary) |
|
Function to return the type of the passed variable. If the passed variable is a dictionary, then it would return a dictionary type. |
type(variable) |
|
Method to return a shallow copy of a dictionary |
dictionary.copy() |
|
Method to create a new dictionary with keys from 'sequence' and values set to 'value' |
dictionary.fromkeys(sequence[, value]) |
|
Method to return value associated with a key in a dictionary or a default value if the key is not in the dictionary |
dictionary.get(key, default) |
|
Method to return 'true' if 'key' is in a dictionary, false otherwise |
dictionary.has_key(key) |
|
Method to remove all elements of a dictionary |
dictionary.clear() |
|
Method to return a list of a dictionary's key-value pairs, as tuples |
dictionary.items() |
|
Method to return a list of a dictionary's keys |
dictionary.keys() |
|
Method to return value associated with a key in a dictionary, or, if the key is not in the dictionary, set the associated value to a default value and return the default |
dictionary.setdefault(key, default) |
|
Method to add a dictionary's key-value pairs to a different dictionary |
dictionary.update(dictionary2) |
|
Method to return a list of a dictionary's values |
dictionary.values() |