deep dive dev (@deepdivedevs) header
deep dive dev (@deepdivedevs) profile picture

teaching computer science fundamentals through quality and practical projects. see pinned tweet for tutorials

Joined July 2024
Photo by deep dive dev (@deepdivedevs)Photo by deep dive dev (@deepdivedevs)Photo by deep dive dev (@deepdivedevs)Photo by deep dive dev (@deepdivedevs)Photo by deep dive dev (@deepdivedevs)Photo by deep dive dev (@deepdivedevs)Photo by deep dive dev (@deepdivedevs)Photo by deep dive dev (@deepdivedevs)Photo by deep dive dev (@deepdivedevs)Photo by deep dive dev (@deepdivedevs)
🔽 Content Directory 🔽 All content posted on this page will be divided into specific series, which you will find below.
3
4
10
1,752
Python Twitter Bot - The Best Project for Beginners Learn how to make a Python Twitter bot that parses RSS feeds and uses the Twitter API to post tweets: youtu.be/xsSXL5iuzDg
1
1
228
Hash Tables - The Most Important Data Structure If you've ever used a dictionary in Python before, then you've used a hash table, which is a data structure that stores key-value pairs and offers extremely fast data retrieval speeds. But how do they work internally?
1
1
2
154
It starts with a hash function - which is a mathematical function that takes in an input (or a key), and returns a fixed-length integer called a hash code. Hash functions have 3 important properties: 1. Deterministic The same key should always return the same hash code 2. Quick to Compute The hash function itself should quickly be able to compute the hash code from the key - regardless of the size of the key 3. Unique Different inputs should result in different outputs - this is sometimes violated in practice, which we will see later
1
1
32
Python Sets Dominate Lists for Quick Searches If your list searches are taking forever, consider converting the list to a set first. Let's find out why ⬇️
1
2
1
6
284
Lists are a linear data structure If we want to search for an element in a list, we have to search each individual element in the list, one by one, until we find what we are looking for In the worst case, if the element we are looking for is at the end of the list, we have to search through N elements. This means we have O(n) lookup time.
1
4
33
Use the Enumerate Function in your Python Loops We often have code like this where we keep track of an index variable, which represents the current position of the list we are looping through But there's a better way to do this - the enumerate function. The enumerate function takes in a sequence and returns an iterable of index and item pairs
1
1
1
3
163
This results in less code and is much cleaner, since we don't have to keep track of an intermediate index variable
1
1
10
If you want to see random code snippets in a variety of languages, follow @codesnippetbot
This post is from a suspended account. Learn more
1
4
146
Never Concatenate Large Lists in Python Concatenating lists with the + operator leads to repeated work. Imagine we want to concatenate 3 lists of integers together with the + operator. Python will first copy the elements from list1 and list2 into a new array. This new array then needs to be concatenated to list3. This is where the inefficiency is. Python will re-copy the elements that were already copied from list1 and list2, then copy the elements from list3. This leads to repeated work, as we copied the elements from list1 and list2 two times. For very large lists, this leads to slower execution.
1
1
6
111
Instead, use the chain function in the itertools library. The chain function creates an iterable out of the lists. The iterable is then able to yield each element in order, without any re-copying of data. We can convert the iterable to a list by surrounding the chain function in list. This leads to no repeated work, since each element is only copied once, and faster execution time.
1
4
39
Learn about Static vs Dynamically typed languages and their inherent tradeoffs: youtube.com/watch?v=87VOk4ao…
2
1
5
455
Static Typing vs Dynamic Typing Most programming languages use static typing or dynamic typing to determine types of variables There are many tradeoffs between the two systems, from performance to safety. Today we will take a closer look at how these typing systems work
1
1
5
101
In statically typed languages, the types of variables are checked at compilation time, before the code is ever ran.
1
1
4
15
Productionize your Python Code with Type Hints youtube.com/watch?v=c3Zz4TOs…
3
1
8
256
🐍 Add type hints to your code using the `typing` library Type hints make your code more readable for humans. They show at a glance what types of data a function expects and returns, helping other developers understand your code faster. Read more about the `typing` library here: docs.python.org/3/library/ty…
3
104
Learn Python Ternary Operators in 60 seconds youtube.com/watch?v=cESpNfcb…
1
1
2
133
The Zen of Python: Exploring Python's Philosophy youtube.com/watch?v=FF1xeyH2…
4
1
4
207
The Zen of Python is a set of guiding principles that shapes the language's philosophy. These 19 aphorisms aren't rules—they're a mindset for writing clear, efficient, and 'Pythonic' code. Today we will go through a few of the most important principles.
1
1
2
42
4,958
Beautiful is Better than Ugly Beautiful code isn't pretty just to be pretty - it's for your future self and others that read your code. Write elegant code that optimizes for maintainability. Use clear and descriptive names for functions and variables so readers can understand at a glance what the code is trying to accomplish. Built-in functions abstract away common logic and makes code more readable - use them instead of implementing your own logic. Use proper spacing and implement error handling when applicable.
1
1
4
74
Python Lambda Functions Lambda functions are small, anonymous functions defined in a single line. They're perfect for simple operations, especially when you need a quick function for things like sorting or mapping. Use Lambda functions to write more concise and readable code.
1
4
65
Have 60 seconds? Learn how Python list comprehensions work youtu.be/QmEXsmF9KHc
5
53
Python F-Strings F-strings (introduced in Python v3.6) offer a concise, readable way to embed expressions inside string literals. Using F-strings are more intuitive than other string formatting methods, like concatenating strings with the (+) operator, or using the .format() method. To use F-strings, add the character "f" before the quote character that starts the string. Then enter any expression within the string definition surrounded by curly-braces. Python will evaluate the expression within the curly braces and add it into the string.
2
7
157
Python List Comprehensions List comprehensions are a Python feature for creating new lists based on the values of an existing list. They are most useful for transforming and filtering items from an existing list in a single line. List comprehensions are a compact way to perform operations that would usually require longer loops, making your code cleaner and often faster.
1
3
6
140
While powerful, list comprehensions can become hard to read if overused. For complex operations or multiple conditions, traditional loops should be used. In practice, when deciding between solutions that are logically equivalent, it is always better to choose the option that is easier to understand.
1
2
60
Ternary Operators: Concise Conditionals The ternary operator allows you to write simple if-else statements in a single line. It's great for quick value assignments based on a condition. Use it for simple, straightforward conditionals to make your code more compact and readable.
4
4
131