Python Bigram formation from given list

In this post we will discuss about bigram formation from a given list in python programming language. We will discuss two methods for creating bigrams. When we are dealing with text classification, sometimes we need to do certain kind of natural language processing and hence sometimes require to form bigrams of words for processing. In … Read more

Convert case of elements in a list of strings Python

Given a list of strings, write a Python program to convert case of all string from lowercase/uppercase to uppercase/lowercase. Input : [‘PrO’, ‘pROG’, ‘RAMmInG’] Output: [‘pro’, ‘prog’, ‘ramming’] Input : [‘fun’, ‘Foo’, ‘BaR’] Output: [‘FUN’, ‘FOO’, ‘BAR’] Method #1 : Convert Uppercase to Lowercase using map function out = map(lambda x:x.lower(), [ ‘PrO’, ‘pROG’, ‘RAMmInG’]) … Read more

Method resolution order in Python Inheritance

Method Resolution Order : Method Resolution Order(MRO) it denotes the way a programming language resolves a method or attribute. Python supports classes inheriting from other classes. The class being inherited is called the Parent or Superclass, while the class that inherits is called the Child or Subclass. In python, method resolution order defines the order … Read more

Operator Overloading in Python

In this article, we’ll learn about operator overloading in Python with examples. We all know what are operators (+, -, <=). In python, operators work for built in classes, but some operator behaves differently with different types. For example ‘+’ operator can add two numbers and also can concatenate two strings. Program: Program: a = … Read more