×
Pete's Cybernetics Space
  • Home
  • About Me!
Sign in Subscribe

python

A collection of 2 posts
The Surprising Behavior of Boolean Indexing in Python: Using Booleans as an index?
python

The Surprising Behavior of Boolean Indexing in Python: Using Booleans as an index?

Python is a language full of interesting quirks, and one of them is how it handles boolean values in indexing. Consider this snippet: my_list = [0, 1] print(my_list[True]) # Output: 1 Why does my_list[True] return 1? To understand this, we need to dive into how Python
Sep 4, 2024 2 min read
Why Python's Floating Point Math Isn't Always Exact
python

Why Python's Floating Point Math Isn't Always Exact

Why Python's Floating Point Math Isn't Always Exact If you've ever tried doing math with decimals in Python, you might have encountered some unexpected results: >>> 0.1 + 0.2 0.30000000000000004 >>> 1.2 - 1.0 0.19999999999999996
Sep 4, 2024 1 min read
Page 1 of 1
Pete's Cybernetics Space © 2025
Powered by Ghost