
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 26504 Articles for Server Side Programming

2K+ Views
We are given with the two strings let’s say str1 and str2 and the task is to find the count of common characters in two strings i.e. if str1[i] = str[j], then they will be considered as a pair and count will increased to 1 and if str1[i]!=str2[j] then they willn’t be considered as a pair and count willn’t increase to 1.For ExampleInput − str1 = “hello” str2 = “heoo” Output − count is: 3Explanation − str1[0] = str2[0] i.e. h ; str1[1] = str2[1] i.e. e ; str1[2]!=str2[2] i.e. l and o; str1[3]=str2[3] i.e. o. So, the ... Read More

586 Views
We are given a string of any length and the task is to convert the string having uppercase letters to lowercase letters and lowercase letters to uppercase letters.For ExampleInput − string str = ”Welcome To The Site!”Output − wELCOME tO tHE sITE!Explanation − converted the letters W, T, T, S to lowercase and letters e, l, c, o, m, e, o, , i, t, e to uppercase and it doesn’t perform any operations to the special characters.Input − string str = ”HELLO”Output − helloExplanation − converted the letters H, E, L, L, E to lowercase.This can be done using two different approachesUsing inbuilt functions provided by ... Read More

2K+ Views
It is possible to have a list whose inner elements are also lists. In such cases we may come across a need when we have to find out the common elements among these inner lists. In this article we will find out the approaches to achieve this.With map and intersectionIntersection is a simple mathematical concept of finding the common elements between different sets. Python has the set method which returns a set that contains the similarity between two or more sets. So we first convert the elements of the list into set through a map function and then apply the ... Read More

3K+ Views
During data analysis we face scenarios to convert every element of a list into a sublist. So in this article we will need to take a normal list as an input and convert into a list of lists where each element becomes a sublist.Using for loopThis is a very straight forward approach in which we create for loop to read each element. We read it as a list and store the result in the new list.Example Live DemoAlist = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'] #Given list print("Given list: ", Alist) # Each element as list NewList= [[x] for x ... Read More

861 Views
Converting from one collection type to another is very common in python. Depending the data processing needs we may have to convert the key value pairs present in a dictionary to pairs representing tuples in a list. In this article we will see the approaches to achieve this.With inThis is a straight forward approach where we just consider theExample Live DemoAdict = {30:'Mon', 11:'Tue', 19:'Fri'} # Given dictionary print("The given dictionary: ", Adict) # Using in Alist = [(key, val) for key, val in Adict.items()] # Result print("The list of tuples: ", Alist)OutputRunning the above code gives us ... Read More

617 Views
In python data analysis, we may come across situation when we need to compare two lists and find out if they are identical meaning having same elements or not.Exmple Live DemolistA = ['Mon', 'Tue', 'Wed', 'Thu'] listB = ['Mon', 'Wed', 'Tue', 'Thu'] # Given lists print("Given listA: ", listA) print("Given listB: ", listB) # Sort the lists listA.sort() listB.sort() # Check for equality if listA == listB: print("Lists are identical") else: print("Lists are not identical")OutputRunning the above code gives us the following result −Given listA: ['Mon', 'Tue', 'Wed', 'Thu'] Given listB: ['Mon', 'Wed', 'Tue', 'Thu'] Lists are identicalWith ... Read More

267 Views
In python data analysis we may come across a scenario to check if a given substring is part of a bigger string. We will achieve this through the following programs.With findThe find function finds the first occurrence of the specified value. If the value is not found then it returns -1. We will apply this function to the given string and design a if clause to find out is substring is part of a string.Example Live DemoAstring = "In cloud 9" Asub_str = "cloud" # Given string and substring print("Given string: ", Astring) print("Given substring: ", Asub_str) if (Astring.find(Asub_str) == -1): ... Read More

6K+ Views
Python provides various methods to check if one list is a subset of another like 'all()' function and also by using 'issubset()' function to perform this check effectively. The three primary approaches used for checking if one list is a subset of another in Python are as follows. all() function : Checks if all elements in list of an iterable are true. issubet() method : Used in python sets for collecting of unique elements. intersection() method : ... Read More

1K+ Views
Given a list, we may need to check for the sequence of its elements. In this article we will find out if the elements present in the list are in a strictly increasing order. Below programs achieve that objective.With all and zipIn this approach we first slice each element compare its value to the next element that is sliced. If all such comparisons hold true then we conclude the list is strictly in increasing order.Example Live DemolistA = [11, 23, 42, 51, 67] #Given list print("Given list : ", listA) # Apply all and range if (all(i < j for i, ... Read More

6K+ Views
Lists are the most widely used data collectios in python. We may come across situation when we need to know if the given list is already sorted or not. In this article we will see the approaches to achieve this.With sortWe take a copy of the given list, apply sort function to it and store that copy as a new list. Then we compare it with the original list and check if they are equal or not.Example Live DemolistA = [11, 23, 42, 51, 67] #Given list print("Given list : ", listA) listA_copy = listA[:] # Apply sort to copy listA_copy.sort() ... Read More