Python can represent floats in binary but cannot use bit operations (&, |, ^, ~, >>, and <<) on them. Why? Let’s take bitwise conjunction operation: >>100.0 & 101.0 # raises a TypeError >>100 & 101 # works fine outputting…
Category: Python
BFS and DFS are two fundamental graph traversal algorithms that have many practical applications in computer science. In this article, we’ll explore the key differences between these two algorithms and their advantages and disadvantages. Applications of BFS and DFS DFS…
Jump to: venv VS virtualenv venv Step-by-Step Guide virtualenv Step-by-Step Guide venv VS virtualenv There are two commonly used libraries that can be used to create virtual environments in Python: virtualenv: a popular third-party package that provides a way to…
Python implementation of the RSA Encryption Algorithm. Quick reference Generating the keys Encrypting Decrypting Algorithm requirements Generating the keys Choose two prime numbers (p, q), such as p is not equal to q. # TODO implement prime number generator #…
A Fibonacci sequence is a series of integers where the next number is found by adding up the two numbers before it The formula can be visualised as follows fibonacci(n) = fibonacci(n-1) + fibonacci(n-2) 0, 1, 1, 2, 3, 5,…
The best course on Dynamic Programming happened to be in JavaScript. Because Python has some particularities in how it handles data structures and organises stack frames, here is a Python version of the functions explained in the course. The structure…
Efficient Pandas: ways to save space and time The first step to reduce memory usage is to load only columns that are necessary for analysis by utilizing usecols argument in pd.read_csv(): pd.read_csv(url, usecols=[column names/indexes]). The second – is to specify…
Quick ref pytest will execute all the files of format test_* or *_test in the current directory and subdirectories. It requires the test function names to start with test. pytest -v for verbose output pytest -q, –quiet less verbose pytest…
Template for Dash application with multiple tabs and callback definitions in different files. As a project grows, there is a need to organize the repository for clarity and ease of maintenance. Here’s a strategy for breaking out a Dash app…
Basic Jinja templates syntax {% … %} Statements. Add control flow and looping inside the templates {{ … }} Expressions. Evaluate expression, variable or function call {# … #} Comments # … ## Line Statements {% raw %} {% endraw…