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
Problem Write an algorithm in Python to check if two strings are permutations of each other Solution Let us differentiate between permutations and combinations. An easy way is to think about permutations in terms of lists and combinations in terms of sets. Take a look at the code snippets below… Code Thanks for visiting. Please
Problem In this beginner level code snippet, we are going to test multiple variables against a value in Python. Check out the code snippet below Code Thanks for visiting. Please use the comments section below for feedback
Problem Given a string of characters. Implement an algorithm in Python to check if the string has all unique characters. Solution One solution is to get the unique characters in the string using a set. If the length of the input string is the same as the length of the set then the string has
Introduction Python programming language does not have a main function to mark the entry point of the program as in C++. Any Python script (i.e. module) can have executable code, function and class definitions. When a script is passed to the Python interpreter, the executable code gets run automatically. In other words, a module can
Introduction Welcome to a new code snippets post. Today, we are going to summarize the use of with statement and context managers in Python. In coding, a typical scenario is to acquire a resource, use it and finally release the resource. If an exception occurs, the program may not have a chance to free the
Introduction Software quality assurance is extremely important in software development. The purpose of testing is to uncover serious defects before pushing products to production. Testing should be part of team culture and every member should participate.Test engineers can do black box, integration and system level testing. on the other hand, developers write unit tests. Testing
Introduction Today, we are going to talk about base64 encoding in Python. Understanding how characters are represented is very important to make sense of base64. For beginners, I highly recommend that you check the following article. It explains how Python handles Unicode and string data types. Let us get started… What is base64 encoding? Base64
Introduction Welcome to a new code snippet in Python. This post is a beginner level one in which we are going to implement a basic Python class to represent a circle and be able to compute the area using different methods. You will learn how to define a class in Python, use default parameter values