Server Side Programming Articles - Page 2360 of 2650

Generate a graph using Dictionary in Python

karthikeya Boyini
Updated on 30-Jul-2019 22:30:23

2K+ Views

The graphs can be implemented using Dictionary in Python. In the dictionary, each key will be the vertices, and as value, it holds a list of connected vertices. So the entire structure will look like Adjacency list of a graph G(V, E). We can use the basic dictionary object, but we are using default dict. It has some additional features. It has one additional writable instance variable. We are providing a text file, which contains the number of vertices, number of edges, names of vertices, and the list of edges. For undirected graph, we are providing two edges like ... Read More

Python program to find common elements in three lists using sets

Sumana Challa
Updated on 09-Jun-2025 13:49:15

1K+ Views

List is one of the built-in data types in Python, which is a sequence of comma-separated items, enclosed in square brackets [ ]. For example, consider the following lists as input - list1 = [5, 10, 15, 20, 25] list2 = [2, 5, 6, 7, 10, 15, 18, 20] list3 = [10, 20, 30, 40, 50, 60] We will find the common elements in three lists, and the output returned should be - [10, 20] Following are the ways to find common elements in three lists using Sets in Python - Using set.intersection() The set.intersection() method is used ... Read More

Break a list into chunks of size N in Python

Sumana Challa
Updated on 09-Jun-2025 14:25:31

630 Views

The objective is to break a list into chunks of a specific size (n), that is, splitting a list into sublists where each sublist contains n elements. For example, if the list is [12, 33, 11, 56, 44, 89, 23, 34, 12] and the chunk size is 3. Then the output has to be - [[12, 33, 11], [56, 44, 89], [23, 34, 12]]. To break a list into chunks of size n in Python, we use list comprehensions, Numpy library, slicing and others. Let's discuss all the approaches in detail with examples - Using List Comprehension List comprehension provides ... Read More

Send mail from your Gmail account using Python

Samual Sam
Updated on 30-Jul-2019 22:30:23

17K+ Views

In this article, we will see how we can send email with attachments using Python. To send mail, we do not need any external library. There is a module called SMTPlib, which comes with Python. It uses SMTP (Simple Mail Transfer Protocol) to send the mail. It creates SMTP client session objects for mailing. SMTP needs valid source and destination email ids, and port numbers. The port number varies for different sites. As an example, for google the port is 587. At first we need to import the module to send mail. import smtplib Here we are also ... Read More

Tracking bird migration using Python-3

karthikeya Boyini
Updated on 30-Jul-2019 22:30:23

478 Views

In some Research works, Researchers uses GPS modules to track the animal behavior. They can track how they are travelling to different places in different time of a year etc. In this example we use that kind of dataset to get an idea, how Birds are moving in different places. In this dataset there are the location details from GPS module are stored. The complete dataset is in CSV form. In that file, there are different fields. The first one is Bird Id, then date_time, Latitude, longitude and speed. For this Task, we need some modules that can be used ... Read More

Shell Sort program in C#

George John
Updated on 27-Jun-2020 06:24:13

869 Views

Shell Sort allows the exchange of items that are far apart in the array and then reduces the gap between them. This is a sort of generalization of Insertion Sort. Shell Sort is known as such as it was published by Donald Shell at first.A program that demonstrates shell sort in C# is given as follows −Example Live Demousing System; namespace ShellSortDemo {    public class Example {       static void shellSort(int[] arr, int n) {          int i, j, pos, temp;          pos = 3;          while (pos > ... Read More

Simple Chat Room using Python

Samual Sam
Updated on 03-Sep-2020 16:10:11

3K+ Views

In this article we will see how to make a server and client chat room system using Socket Programming with Python.The sockets are the endpoints of any communication channel. These are used to connect the server and client. Sockets are Bi-Directional. In this area, we will setup sockets for each end and setup the chatroom system among different clients through the server. The server side has some ports to connect with client sockets. When a client tries to connect with the same port, then the connection will be established for the chat room.There are basically two parts. The server side ... Read More

How to multiply a given number by 2 using Bitwise Operators in C#?

Ankith Reddy
Updated on 27-Jun-2020 06:43:29

4K+ Views

A number can be multiplied by 2 using bitwise operators. This is done by using the left shift operator and shifting the bits left by 1. This results in double the previous number.A program that demonstrates multiplication of a number by 2 using bitwise operators is given as follows.Example Live Demousing System; namespace BitwiseDemo {    class Example {       static void Main(string[] args) {          int num = 25, result;          result = num

Python Program to detect the edges of an image using OpenCV

karthikeya Boyini
Updated on 30-Jul-2019 22:30:23

660 Views

In this problem, we will see how Python can detect edges of an image or video file. To achieve this, we need the OpenCV library. The OpenCV library is mainly designed for computer vision. It is open source. Originally it was designed by Intel. This is free to use under open-source BSD license. To use the OpenCV functionality, we need to download them using pip.The OpenCV will download the Numpy module. That will also be needed. sudo pip3 install opencv-python As input, in this case, we have used one video file. We can also use our webcam to ... Read More

How to perform Merge Sort using C#?

Arjun Thakur
Updated on 27-Jun-2020 06:50:48

2K+ Views

Merge Sort is a sorting algorithm that uses the divide and conquer method. It divides the array into two parts and then calls itself for each of these two parts. This process is continued until the array is sorted.A program that demonstrates merge sort in C# is given as follows −Example Live Demousing System; namespace QuickSortDemo {    class Example {       static public void merge(int[] arr, int p, int q, int r) {          int i, j, k;          int n1 = q - p + 1;          int ... Read More

Advertisements