
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 33676 Articles for Programming

214 Views
Let's consider a list containing many strings of different lengths. In this article we will see how to club those elements into groups where the strings are of equal length in each group.With for loopWe design a for loop which will iterate through every element of the list and happened it only to the list where its length matches with the length of existing element.Example Live DemolistA = ['Monday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] # Given list print("Given list : ", listA) # Categorize by string size len_comp = lambda x, y: len(x) == len(y) res = [] for sub_list in listA: ... Read More

3K+ Views
Correlation refers to some statistical relationships involving dependence between two data sets. While linear regression is a linear approach to establish the relationship between a dependent variable and one or more independent variables. A single independent variable is called linear regression whereas multiple independent variables is called multiple regression.CorrelationSimple examples of dependent phenomena include the correlation between the physical appearance of parents and their offspring, and the correlation between the price for a product and its supplied quantity.We take example of the iris data set available in seaborn python library. In it we try to establish the correlation between the ... Read More

605 Views
In this article we we want to convert a given images into a text bases image also called ASCII image.Below is the Python program which will take an input imagee and various functions to convert them into grayscale picture and then apply the ASCII characters to create different patterns insert the image. Finally the emails comes text based image this is a series of plane ASCII characters.Examplefrom PIL import Image import os ASCII_CHARS = [ '#', '?', '%', '.', 'S', '+', '.', '*', ':', ', ', '@'] def resize_image(image, new_width=25): (input__width, input__height) = image.size aspect_ratio = input__height/float(input__width) ... Read More

2K+ Views
There are scenarios when we need to get a list containing only the Boolean values like true and false. In this article how to create list containing only Boolean values.With rangeWe use range function giving it which is the number of values we want. Using a for loop we assign true or false today list as required.Example Live Demores = [True for i in range(6)] # Result print("The list with binary elements is : " ,res)OutputRunning the above code gives us the following result −The list with binary elements is : [True, True, True, True, True, True]With * operatorThe * operator ... Read More

240 Views
Suppose we have a list of lists in which each sublist has two elements. One element of each sublist is common across many other subjects of the list. We need to create a final list which will show sublists grouped by common elements.With set and mapIn the given list the first element is a string and the second element is a number. So we create a temp list which will hold the second element of each sublist. Then we compare is sublist with each of the element in the temp list and designer follow to group them.Example Live DemolistA = [['Mon', ... Read More

854 Views
The given task is to perform an alternate summation on a Python List. For example, adding the elements at even indices (0, 2, 4) or odd indices (1, 3, 5), depending on the requirement. This means we need to add every other element from the given list. Let us see an input scenario - Scenario Input: [11, 22, 33, 44, 55] Output: 99 Explanation: Here, we are going to add the elements at the even indices by using the slicing [::2]. Alternate Element Summation Using sum() Function The alternate element summation in a list (Python) can ... Read More

182 Views
We have a list whose elements are numeric. Many elements are present multiple times. We want to create sub list so the frequency of each element along with the elements itself.With for and appendIn this approach we will compare each element in the list with every other elements after it. If there is a match then count will be incremented and both the element and the count will be made into a subsist. List will be made which should contain subsists showing every element and its frequency.Example Live Demodef occurrences(list_in): for i in range(0, len(listA)): a = ... Read More

1K+ Views
We have a Python list which contains both string and numbers. In this article we will see how to sum up the numbers present in such list by ignoring the strings.With filter and isinstanceThe isinstance function can be used to filter out only the numbers from the elements in the list. Then we apply and the sum function and get the final result.Example Live DemolistA = [1, 14, 'Mon', 'Tue', 23, 'Wed', 14, -4] #Given dlist print("Given list: ", listA) # Add the numeric values res = sum(filter(lambda i: isinstance(i, int), listA)) print ("Sum of numbers in listA: ", res)OutputRunning the ... Read More

5K+ Views
While analyzing data using Python data structures we will eventually come across the need for accessing key and value in a dictionary. There are various ways to do it in this article we will see some of the ways.With for loopUsing a for loop we can access both the key and value at each of the index position in dictionary as soon in the below program.Example Live DemodictA = {1:'Mon', 2:'Tue', 3:'Wed', 4:'Thu', 5:'Fri'} #Given dictionary print("Given Dictionary: ", dictA) # Print all keys and values print("Keys and Values: ") for i in dictA : print(i, dictA[i])OutputRunning the above code ... Read More

3K+ Views
When we use a Python list, will be required to access its elements at different positions. In this article we will see how to get the index of specific elements in a list.With list.IndexThe below program sources the index value of different elements in given list. We supply the value of the element as a parameter and the index function returns the index position of that element.Example Live DemolistA = [11, 45, 27, 8, 43] # Print index of '45' print("Index of 45: ", listA.index(45)) listB = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'] # Print index of 'Wed' print("Index of ... Read More