Found 34490 Articles for Programming

Stack and Queue in Python using queue Module

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

456 Views

In Python, it is very easy to implement stack and queue data structures. Stack is called LIFO because Stack works on the principle of "Last-in, first-out" and Queue is called FIFO because Queue works on the principle of "First-in, first-out", and the inbuilt functions in Python make the code shorter and simple. The Queue module implements multi-producer, multi-consumer queues and It is especially useful in threaded programming when information must be exchanged safely between multiple threads. The Queue class in this module implements all the required locking semantics and it depends on the availability of thread support in Python. This ... Read More

Extracting MAC address using Python

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

2K+ Views

We know that the MAC address is a hardware address which means it is unique for the network card installed on our PC. It is always unique that means no two devices on a local network could have the same MAC addresses. The main purpose of MAC address is to provide a unique hardware address or physical address for every node on a local area network (LAN) or other networks. A node means a point at which a computer or other device (e.g. a printer or router) will remain connected to the network. Method1 Using uuid.getnode() In this example getnode() ... Read More

How to check if a string is a valid keyword in Python?

AmitDiwan
Updated on 11-Aug-2022 11:45:16

2K+ Views

To check if a string is a valid keyword, import the keyword module and use the iskeyword() method. With that, you can directly display all the keywords at once and verify. Let’s say the following is our input − else The following is the output. The “else” is a keyword in Python − Keyword Check if a string is a valid keyword in Python Example import keyword # Create a List myList = ["for", "amit", "val", "while"] # Display the List print("List = ", myList) keyword_list = [] non_keyword_list = [] # Looping and ... Read More

Send mail from your Gmail account using Python

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

16K+ 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

273 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

687 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

2K+ 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

474 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