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

Check for Palindrome in Python

In the previous article we explored pattern searching in Python, on this article we will see how we can check for Palindrome in Python logic. Before we delve further, think of the date 10-02-2001 which can be expressed as 10022001. From either side, left to right or right to left we arrive at the same … Read more

Pattern Searching in Python

In the previous article we saw how String comparison works, in this article we will see how we can deal with a common computer science problem ..we have a large text and then we have a pattern. Our task is to find all occurrences of this pattern within this large text. This is a very … Read more

Comprehensions in Python

In the previous article we saw how we could obtain the even and odd elements of a list, separately and return them. Now we will explore the concept of Comprehensions in Python with regards to lists, sets and dictionaries. What is List Comprehension? List Comprehension provides us a shortcut to create a new list from … Read more

While Loops in Python

In the previous lesson we have seen why loops are essential in programming languages, in this article we will explore a common type of loop present, that is the While loops in Python. While loop is a loop which first checks whether a particular condition matches, and then executes the statements which are embedded within … Read more

Loops in Python

In the previous article we have seen the Calculator implementation , now we will go through the concept of loops in Python. Looping structures are instrumental in reducing the repeated statements or complexity of code. Let us look at the example of multiplication tables. We need to write a program that accepts a user input … Read more

Binary to Decimal Conversion in Python

As we have seen in the previous article, the various ways in which we can convert from decimal to binary. Let us now explore the reverse that is Binary to Decimal Conversion in Python. Imagine that we are given a string that represents binary value of a number, we need to write a function that … Read more

String Operations in Python Part 1

In the previous article we saw the use of Formatting Strings in Python, in this article we are going to discuss operations on Strings and methods of Strings. Working with String Operations in Python The first operation we are going to discuss is checking whether a given string is a substring of another string or … Read more