LCM of two Numbers in Python

In the previous article we explored about GCD and it’s implementation in Python. Now let us explore the concept of LCM and how we can arrive at the LCM of two Numbers in Python. Before we delve further into Python let us look at a problem which can further/or revise our understanding of LCM. We … Read more

GCD of two numbers in Python

In the previous article, we explored two different approaches towards obtaining the factorial of a number. In this current article we will explore how we can obtain the GCD of two numbers in Python. The common divisor of several integers is a number that can be a divisor of each number in the specified set. For example, … Read more

Factorial Program in Python

In the previous article we have seen the logic and code for obtaining the count of the digits in a number, in this article we will see how we can obtain the Factorial of any user-entered number in Python. Before we discuss the Factorial Program in Python, let us revise the concept of Factorial. The … Read more

Membership Test Operators in Python

In the previous article we have gone through the bitwise operators available in Python, to further our knowledge of Operators in Python we will look at how to effectively utilize Membership Operators. Sometimes we are required to validate whether a certain data collection possesses specified items,  there are inbuilt operators called membership operators in Python , designed to … Read more

Program to return Smaller list Elements in Python

In the previous article we discussed handling of slicing on tuples, strings and lists in python. Now let us explore how we can handle a problem related to list concept. We need to write a function that takes a list as input, also takes a value for ‘x’ as input. The function should return all … Read more

Program to separate Even and Odd List Elements

In the previous article we explored how we could write a function to return the smaller elements from a list. Now we will apply similar logic to write a function to separate even and odd list elements. We are given a list, we need to write a function that takes the list as argument and … Read more

Decimal to Binary in Python

In the previous article we discussed how a string can be reversed, now let us explore number system conversions in Python. We are given a non-negative integer, our task is to write a function that takes the integer as an argument and then returns the binary value. The result should be stored in a string … Read more

Reverse a String in Python

In the previous article, we were required to validate if the reversed string or string elements were the same as the one in original ordering. Hence, we saw two ways in which it could be done…in this article we will explore a bit more of the same concept of how to reverse a string in … Read more

Count Distinct Elements in a List in Python

In the previous article we discussed how to to obtain the average/mean of a given list, now we will see how we can write a program to Count Distinct Elements in a List in Python. Suppose we are given a list L=[10,20,10,30,30,20], we see that there some of the elements occur multiple times within the … Read more

String Operations in Python Part 2

In the previous article we saw various string operations like concatenation, and use of index( ) and rindex( ) functions. Now we will look at more String Operations in Python. Utilizing String Operations in Python len( ): It returns the number of characters in the string. upper( ): It converts the lowercase characters in the … Read more