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

Average or Mean of a List in Python

In the previous article, we explored the concept of Comprehensions in Python. Now let us look at how we can obtain the average or mean of a list in Python. Let us look at an example, we have a list l1: l1=[10,20,30,40] There are four elements in the list, and the average can be obtained … Read more

Slicing in Python (Tuples, Strings, Lists)

In the previous article we explored the conversions of Binary to Decimal. Now we will explore the concept of slicing, slicing in Python is the process of extracting a specific sub portion of an iterable data structure, according to the user-specified criteria. Very often, it is necessary to get not one certain element, but a … Read more

String Comparison in Python

In the previous article we discussed some of the frequent string operations, now let us look at comparing the values or characters of strings. Python allows various different comparison operators to be allowed for this purpose. Operators for String Comparison in Python Let us examine a program using comparison operators: How does the comparison of … Read more