Programming Articles

Page 617 of 2547

Merge two sorted arrays in Python using heapq?

Samual Sam
Samual Sam
Updated on 25-Mar-2026 623 Views

The heapq module in Python provides an efficient way to merge multiple sorted iterables into a single sorted sequence. The heapq.merge() function is specifically designed for merging sorted arrays while maintaining the sorted order. The heapq.merge() Function The heapq.merge() function accepts multiple sorted iterables and returns an iterator that produces elements in sorted order. It uses a min-heap internally to efficiently merge the arrays without loading everything into memory at once. Syntax heapq.merge(*iterables, key=None, reverse=False) Basic Example Here's how to merge two sorted arrays using heapq.merge() ? import heapq ...

Read More

Creating child process using fork() in Python

karthikeya Boyini
karthikeya Boyini
Updated on 25-Mar-2026 2K+ Views

The fork() function in Python allows you to create child processes by duplicating the current process. This is a fundamental concept in Unix-like systems for process management and multithreading environments. When fork() is called, it creates an exact copy of the calling process. The return value helps distinguish between parent and child processes: 0 indicates the child process, a positive value indicates the parent process (containing the child's PID), and a negative value indicates an error occurred. Understanding fork() Return Values The fork() function returns different values depending on which process you're in ? Child ...

Read More

Play a video in reverse mode using Python OpenCv

karthikeya Boyini
karthikeya Boyini
Updated on 25-Mar-2026 808 Views

OpenCV (Open Source Computer Vision) is a powerful library for image and video processing in Python. One interesting application is playing videos in reverse mode by manipulating the frame order. Application Areas of OpenCV Facial recognition system Motion tracking Artificial neural network Deep neural network Video streaming Installation For Windows ? pip install opencv-python For Linux ? sudo apt-get install python-opencv Steps to Play Video in Reverse Import OpenCV library (cv2) Load the video file as input Extract all frames from the video and ...

Read More

Read and Write to an excel file using Python openpyxl module

karthikeya Boyini
karthikeya Boyini
Updated on 25-Mar-2026 6K+ Views

Python provides the openpyxl module for reading and writing Excel files. This powerful library allows you to create, modify, and extract data from Excel workbooks programmatically. Installation Install openpyxl using pip ? pip install openpyxl Getting Sheet Title When you create a new workbook, it comes with a default sheet ? import openpyxl my_wb = openpyxl.Workbook() my_sheet = my_wb.active my_sheet_title = my_sheet.title print("My sheet title: " + my_sheet_title) My sheet title: Sheet Changing Sheet Title You can customize the sheet name by modifying the ...

Read More

Decimal Functions in Python

karthikeya Boyini
karthikeya Boyini
Updated on 25-Mar-2026 13K+ Views

The Decimal module in Python provides precise decimal floating-point arithmetic, avoiding the common rounding errors that occur with standard floating-point numbers. This module is particularly useful for financial calculations where precision is critical. To use the Decimal module, you need to import it first ? import decimal Square Root and Exponential Functions The sqrt() method calculates the square root of a decimal number, while exp() returns ex for a given decimal value ? import decimal my_dec = decimal.Decimal(25.36) print(my_dec) print('Square Root is:', my_dec.sqrt()) print('e^x is:', my_dec.exp()) 25.3599999999999994315658113919198513031005859375 Square ...

Read More

Create a Website Alarm Using Python

Samual Sam
Samual Sam
Updated on 25-Mar-2026 590 Views

In this section we will see how to create a website alarm system using Python. This tool automatically opens a specified website URL in your browser at a predetermined time. Problem Statement Create a program that opens a website URL on the browser by taking a website URL and time as input. When the system time reaches the specified time, the webpage will be opened automatically. We can store different web pages in our bookmark sections. Sometimes we need to open some web pages every day at a specific time to do some work. For that purpose, ...

Read More

Python Program to calculate the Round Trip Time (RTT)

karthikeya Boyini
karthikeya Boyini
Updated on 25-Mar-2026 2K+ Views

Here we will see how Python can be used to get the Round Trip Time (RTT). The RTT is the time taken by the entire trip of a signal — the time between when a signal is sent and when the acknowledge signal is received. The RTT results vary based on different parameters like ? The data transfer rate of the sender's side. The nature of the transmission media. The actual distance between the sender and receiver. The number of nodes between sender and receiver. ...

Read More

Birthday Reminder Application in Python

karthikeya Boyini
karthikeya Boyini
Updated on 25-Mar-2026 925 Views

In this tutorial, we will create a birthday reminder application using Python that checks for birthdays on the current date and sends system notifications. Problem Statement Create a Python application that checks whether there is any birthday on the current day. If it's someone's birthday from our list, send a system notification with their name. We need a lookup file to store dates and names. Create a text file named birth_day_lookup.txt with this format ? 10-January John Doe 15-March Jane Smith 22-December Alice Johnson ...

Read More

Unix filename pattern matching in Python

Samual Sam
Samual Sam
Updated on 25-Mar-2026 2K+ Views

Unix filename pattern matching in Python is accomplished using the fnmatch module. This module provides shell-style pattern matching capabilities to compare filenames against patterns and returns True or False based on matches. Importing the fnmatch Module First, import the fnmatch module from Python's standard library ? import fnmatch Unix Wildcard Patterns The fnmatch module supports standard Unix wildcards ? * − Matches any number of characters (including none) ? − Matches exactly one character [seq] − Matches any character in the sequence [!seq] − Matches any character not in the sequence ...

Read More

Python Interface to UNIX syslog library routines

George John
George John
Updated on 25-Mar-2026 396 Views

The syslog module provides a Python interface to the UNIX system logging facility. It allows your Python programs to send messages to the system log, which administrators can monitor for debugging and system monitoring purposes. To use this module, we need to import it ? import syslog syslog.syslog() Method This method sends a string message to the system logger. You can specify a priority level for the message. Syntax syslog.syslog(message) syslog.syslog(priority, message) Parameters: message - String message to log priority - Optional priority level (LOG_DEBUG, LOG_INFO, LOG_NOTICE, LOG_WARNING, ...

Read More
Showing 6161–6170 of 25,466 articles
« Prev 1 615 616 617 618 619 2547 Next »
Advertisements