Introduction On the surface, this question looks innocent but if we dig a bit deeper, things start to get confusing. In this short post, we will provide a summary of differences, however to better understand the topic, I recommend that you check the full article here. Depending on which version of Python we are using
Introduction Welcome to a new Python code snippets post. Below, you can find a summary of helpful Python syntax for that purpose… Let us now take some examples… Sorted dictionary keys This will print… Sorted dictionary values This will print… Sorted dictionary items by value This will print… Sorting in reverse order This will print…
Introduction Comparing strings is a very common task in coding. How do we do that in Java ? well there are tons of content in that regard. I compiled the bare minimum that you need in case you are only looking for the syntax. Take a look… Syntax Summary Let us demonstrate that… Source code
Introduction To check service port numbers on a Unix based operating system, you may use one of the following methods… netstat command netstat command is used to display network related data. It is available on most Unix flavors including MacOS. The syntax may vary so it is recommended to check the manual (ex. man netstat
Introduction This is a frequently asked question in Python. In this article, I will only provide a short summary. For more details, you may refer to the full article here. So what is the deal about the yield keyword in Python ? The yield keyword in Python has to do with generator functions. Let us
Introduction Assume we have a directory structure (ex. product source code) and we want to share it with someone. To do that on Unix, we can tar the directory structure (convert to a single file archive) then compress the file. If we do not pay due attention, original file and directory paths can be retained
Introduction On Unix based operating systems (Linux, MacOS, etc) a common task is to search for files. For example, we may need to search for text files only. In this post, we will demonstrate the command line syntax to filter out binary and executable files and only keep text files. Follow the steps below… Create
Problem In this Python code snippet, we are going to implement a naive run length encoding algorithm to compress strings Solution The idea is very simple, text has redundancy so instead of sending plain text, we can compress text by sending characters and their counts. This is a typical text processing problem that gets asked
Problem Write a Python function that checks if two strings are rotation of each other Solution Rotating a string means inserting a number of characters from the end of the string to the beginning of the string. Any easy trick to check if two strings are rotation of each other is to concatenate one string
Problem Implement an algorithm in Python to check if a given input string is a permutation of another palindrome string Solution If the number of occurrences of all characters in the string is even then the input string can be a permutation of a palindrome string. There is only once exception which is the character