AC
AnkiCollab
AnkiCollab
Sign in
Explore Decks
Helpful
Join Discord
Download Add-on
Documentation
Support Us
Notes in
Week 3 - Python Types and Methods
To Subscribe, use this Key
chicken-football-london-jupiter-seventeen-black
Status
Last Update
Fields
Published
10/15/2024
{{c1::Data structures}} allow us to organize and store data efficiently.
Published
10/15/2024
{{c1::Lists}} are mutable, meaning they can be modified after creation.
Published
10/15/2024
A {{c1::tuple}} is immutable, which means it cannot be changed after creation.
Published
10/15/2024
You create a list in Python using {{c1::square brackets []}}.
Published
10/15/2024
A tuple is created using {{c1::parentheses ()}}.
Published
10/15/2024
{{c1::Dictionary}} keys must be immutable, such as strings, numbers, or tuples.
Published
10/15/2024
A {{c1::set}} is an unordered collection of unique elements.
Published
10/15/2024
You can access list elements by using their {{c1::index}}.
Published
10/15/2024
The {{c1::len()}} function returns the number of elements in a list.
Published
10/15/2024
To add an item to a list, use the {{c1::append()}} method.
Published
10/15/2024
The {{c1::insert()}} method adds an element at a specific position in a list.
Published
10/15/2024
To remove an item from a list, use the {{c1::remove()}} method.
Published
10/15/2024
The {{c1::pop()}} method removes and returns the last item from a list.
Published
10/15/2024
Lists can be concatenated using the {{c1::+}} operator.
Published
10/15/2024
The {{c1::sort()}} method sorts a list in ascending order by default.
Published
10/15/2024
Use the {{c1::reverse()}} method to reverse the elements in a list.
Published
10/15/2024
A {{c1::slice}} can be used to extract a part of a list.
Published
10/15/2024
The {{c1::split()}} method divides a string into a list based on a separator.
Published
10/15/2024
To combine two lists, use the {{c1::extend()}} method.
Published
10/15/2024
The {{c1::copy()}} method creates a shallow copy of a list.
Published
10/15/2024
A {{c1::deepcopy()}} is needed to copy nested lists.
Published
10/15/2024
Use the {{c1::in}} operator to check if an element exists in a list.
Published
10/15/2024
You can iterate over the elements of a list using a {{c1::for loop}}.
Published
10/15/2024
The {{c1::range()}} function generates a sequence of numbers.
Published
10/15/2024
A {{c1::list comprehension}} provides a concise way to create lists.
Published
10/15/2024
In Python, a {{c1::set}} does not allow duplicates.
Published
10/15/2024
Use {{c1::add()}} to insert a new element into a set.
Published
10/15/2024
The {{c1::remove()}} method deletes an element from a set.
Published
10/15/2024
You can check if an element exists in a set using {{c1::in}}.
Published
10/15/2024
Use the {{c1::union()}} method to combine two sets.
Published
10/15/2024
The {{c1::intersection()}} method returns common elements between sets.
Published
10/15/2024
The {{c1::difference()}} method finds elements in one set but not in another.
Published
10/15/2024
A {{c1::dictionary}} consists of key-value pairs.
Published
10/15/2024
You can access a value in a dictionary using its {{c1::key}}.
Published
10/15/2024
Use {{c1::del}} to remove a key-value pair from a dictionary.
Published
10/15/2024
The {{c1::keys()}} method returns all the keys in a dictionary.
Published
10/15/2024
The {{c1::values()}} method returns all the values in a dictionary.
Published
10/15/2024
The {{c1::items()}} method returns all key-value pairs in a dictionary.
Published
10/15/2024
You can iterate over a dictionary using a {{c1::for loop}}.
Published
10/15/2024
The {{c1::get()}} method retrieves the value for a key, or None if the key does not exist.
Published
10/15/2024
To update the value of a key in a dictionary, simply use an {{c1::assignment}}.
Published
10/15/2024
The {{c1::pop()}} method removes and returns the value of a key from a dictionary.
Published
10/15/2024
Use the {{c1::clear()}} method to remove all items from a dictionary.
Published
10/15/2024
You can merge two dictionaries using the {{c1::update()}} method.
Published
10/15/2024
A dictionary comprehension provides a concise way to create dictionaries.
Published
10/15/2024
A {{c1::stack}} is a collection of elements that follows the Last In, First Out (LIFO) principle.
Published
10/15/2024
A stack's {{c1::push}} operation adds an element to the top of the stack.
Published
10/15/2024
The {{c1::pop}} operation removes the element from the top of the stack.
Published
10/15/2024
A {{c1::queue}} is a collection of elements that follows the First In, First Out (FIFO) principle.
Published
10/15/2024
Use the {{c1::append()}} method to enqueue an element in a queue.
Published
10/15/2024
Use the {{c1::pop(0)}} method to dequeue an element from the front of a queue.
Published
10/15/2024
A {{c1::deque}} (double-ended queue) allows elements to be added or removed from both ends.
Published
10/15/2024
To add an element to the front of a deque, use {{c1::appendleft()}}.
Published
10/15/2024
To remove an element from the back of a deque, use {{c1::pop()}}.
Published
10/15/2024
To remove an element from the front of a deque, use {{c1::popleft()}}.
Published
10/15/2024
A {{c1::hash table}} stores data in an associative manner using keys.
Published
10/15/2024
In Python, dictionaries are implemented as {{c1::hash tables}}.
Published
10/15/2024
Hash tables allow for {{c1::constant time complexity (O(1))}} for search, insert, and delete operations.
Published
10/15/2024
{{c1::Collisions}} in hash tables occur when two keys hash to the same index.
Published
10/15/2024
A {{c1::linked list}} is a data structure in which each element points to the next one.
Published
10/15/2024
The first element in a linked list is called the {{c1::head}}.
Published
10/15/2024
The last node in a linked list points to {{c1::None}}.
Published
10/15/2024
A {{c1::singly linked list}} allows traversal in only one direction, from the head to the tail.
Published
10/15/2024
In a {{c1::doubly linked list}}, each node has pointers to both the next and previous nodes.
Published
10/15/2024
To add a node at the beginning of a linked list, you need to update the {{c1::head}} to point to the new node.
Published
10/15/2024
In a linked list, the {{c1::insert()}} function can be used to insert a node at a specific position.
Published
10/15/2024
To delete a node in a linked list, you must update the {{c1::next}} pointer of the previous node to skip the deleted node.
Published
10/15/2024
The {{c1::traverse()}} function allows you to visit each node in a linked list.
Published
10/15/2024
A {{c1::circular linked list}} is one in which the last node points back to the first node.
Published
10/15/2024
In a {{c1::priority queue}}, each element has a priority, and elements are dequeued in order of their priority.
Published
10/15/2024
A {{c1::binary search tree}} (BST) is a tree in which each node has at most two children, and the left child is less than the parent, while the right …
Published
10/15/2024
The root of a binary tree is the {{c1::topmost node}} in the tree.
Published
10/15/2024
In a binary tree, a {{c1::leaf node}} is a node that has no children.
Published
10/15/2024
The depth of a binary tree is the number of edges from the {{c1::root}} to a leaf node.
Published
10/15/2024
A {{c1::balanced tree}} is a binary tree in which the depth of the left and right subtrees differs by at most one.
Published
10/15/2024
A {{c1::heap}} is a binary tree in which each parent node is greater (max-heap) or smaller (min-heap) than its children.
Published
10/15/2024
In a {{c1::trie}} (prefix tree), each node represents a character, and paths from the root to the leaf represent words.
Published
10/15/2024
The {{c1::depth-first search}} (DFS) algorithm explores as far down a branch of the tree or graph as possible before backtracking.
Published
10/15/2024
The {{c1::breadth-first search}} (BFS) algorithm explores all the nodes at the present depth level before moving on to the next level.
Published
10/15/2024
In Python, you can implement a stack using a {{c1::list}} and the append() and pop() methods.
Published
10/15/2024
When you use {{c1::.copy()}} on a list, any change to the original list will {{c2::not affect}} the copied list.
Published
10/15/2024
A {{c1::shallow copy}} only copies the outermost object. Changes to mutable objects inside the copy are {{c2::reflected}} in the original.
Published
10/15/2024
A {{c1::deep copy}} creates a fully independent copy, even for mutable nested objects.
Published
10/15/2024
The {{c1::append()}} method adds an item to the end of a list.
Published
10/15/2024
{{c1::.extend()}} adds elements from another list to the end of the current list.
Published
10/15/2024
The {{c1::insert()}} method adds an element at a specified position in a list.
Published
10/15/2024
{{c1::remove()}} deletes the first occurrence of a specified element from a list.
Published
10/15/2024
The {{c1::pop()}} method removes and returns the last item in a list unless an index is specified.
Published
10/15/2024
A {{c1::slice}} extracts a portion of a list based on start and end indices.
Published
10/15/2024
The {{c1::del}} keyword is used to remove elements from a list or delete the list entirely.
Published
10/15/2024
{{c1::List comprehensions}} allow you to create a new list by iterating over an existing iterable.
Published
10/15/2024
The {{c1::sorted()}} function returns a sorted list, while {{c2::.sort()}} modifies the list in place.
Published
10/15/2024
A {{c1::set}} is a collection of unordered, unique elements.
Published
10/15/2024
The {{c1::add()}} method adds an element to a set.
Published
10/15/2024
{{c1::discard()}} removes an element from a set if it exists, without raising an error if it doesn't.
Published
10/15/2024
The {{c1::union()}} method returns the union of two sets.
Published
10/15/2024
The {{c1::intersection()}} method returns the common elements between two sets.
Published
10/15/2024
The {{c1::difference()}} method returns elements in one set but not in another.
Published
10/15/2024
A {{c1::dictionary}} is a collection of key-value pairs, where keys must be unique and immutable.
Published
10/15/2024
The {{c1::.get()}} method retrieves the value of a key without raising an error if the key does not exist.
Published
10/15/2024
To add or update a key-value pair in a dictionary, use {{c1::assignment}}.
Published
10/15/2024
The {{c1::.update()}} method merges another dictionary into the original dictionary.
Published
10/15/2024
The {{c1::.pop()}} method removes and returns the value for a specified key in a dictionary.
Published
10/15/2024
The {{c1::.items()}} method returns a view of the dictionary's key-value pairs.
Published
10/15/2024
The {{c1::.keys()}} method returns a view of the dictionary's keys.
Published
10/15/2024
The {{c1::.values()}} method returns a view of the dictionary's values.
Published
10/15/2024
The {{c1::clear()}} method removes all key-value pairs from a dictionary.
Published
10/15/2024
A {{c1::tuple}} is an immutable sequence of elements, meaning it cannot be changed after creation.
Published
10/15/2024
A {{c1::list}} is mutable, meaning elements can be added, removed, or changed.
Published
10/15/2024
In Python, {{c1::indexing}} starts at 0, meaning the first element in a list or string is at position 0.
Published
10/15/2024
A {{c1::string}} is an immutable sequence of characters.
Published
10/15/2024
The {{c1::split()}} method divides a string into a list based on a separator.
Published
10/15/2024
{{c1::String slicing}} allows you to access a subset of a string by specifying start and end positions.
Published
10/15/2024
The {{c1::join()}} method combines elements of a list into a string with a separator.
Published
10/15/2024
The {{c1::find()}} method returns the lowest index of the substring if found, or -1 if not found.
Published
10/15/2024
The {{c1::replace()}} method replaces occurrences of a substring with another substring.
Published
10/15/2024
The {{c1::startswith()}} method checks if a string starts with a specific substring.
Published
10/15/2024
The {{c1::endswith()}} method checks if a string ends with a specific substring.
Published
10/15/2024
In Python, {{c1::len()}} is used to find the length of a list, string, or other iterable.
Published
10/15/2024
The {{c1::type()}} function returns the type of an object.
Status
Last Update
Fields