Python Float Decimal to Octal

Problem Formulation: Given a float number. How to convert it to octal representation? Examples: Consider the following desired conversions from float decimal numbers to their converted float octal numbers. input: 3.14 output: 3.1075 input: 0.01 output: 0.005 input: 12.325 output: 14.246 You can play with some examples here: Solution: The following code function float_to_octal() takes … Read more

You Cannot Use Python Regex in startswith(). Do This Instead.

I’m sitting in front of my computer refactoring Python code and have just thought of the following question: Can You Use a Regular Expression with the Python string.startswith() Method? The short answer is no. The string.startswith() method doesn’t allow regular expression inputs. And you don’t need it because regular expressions can already check if a … Read more