Escape Sequences and Raw Strings in Python

In the previous article we saw some string programs to demonstrate common characteristics of Strings in Python, now let us examine the concept of escape sequences and raw strings in Python. Imagine the below statement as part of a program The program fails to execute simply because the apostrophe interferes with the program’s syntax where … Read more

String Formatting in Python

In the previous article, we saw the use of escape sequences and raw strings now let us discuss Formatted Strings in Python, When we want to print formatted data, suppose combining multiple strings we can use the + operator. While something like this would work in practice, it would require a lot of plus operator … 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

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

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

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