Programming Articles

Page 57 of 2547

Finding the First Even Number in a List using Python

Tapas Kumar Ghosh
Tapas Kumar Ghosh
Updated on 27-Mar-2026 625 Views

Finding the first even number in a list is a common programming task in Python. This can be accomplished using various approaches including the next() function, recursion, filter() with lambda, and simple loops. Given a list like [21, 33, 12, 11, 61, 78], the first even number would be 12 since it's the first number divisible by 2. Syntax The key functions used in these examples: next() − Returns the next item from an iterator filter() − Filters elements based on a condition lambda − Creates anonymous functions for short operations Using next() ...

Read More

Find the Common Keys from two Dictionaries in Python

Tapas Kumar Ghosh
Tapas Kumar Ghosh
Updated on 27-Mar-2026 1K+ Views

Dictionaries are key-value data structures in Python where each key is unique. Finding common keys between two dictionaries is a frequent task in data processing and comparison operations. Let's explore different methods to find common keys with this example ? Input: dict1 = {'I': 10, 'II': 20, 'III': 30, 'IV': 40} dict2 = {'II': 40, 'V': 60, 'VI': 80, 'I': 90} Expected Output: {'I', 'II'} Using Set Intersection with keys() The most efficient approach uses set intersection to find common keys ? dict1 = {'A': 20, 'T': 30, 'W': 40, ...

Read More

Convert Matrix to Custom Tuple Matrix in Python

Tapas Kumar Ghosh
Tapas Kumar Ghosh
Updated on 27-Mar-2026 618 Views

In Python, a tuple is an immutable data structure represented by parentheses (). Converting a matrix to a custom tuple matrix means transforming each element in the matrix into a single-element tuple. This creates a matrix where each value becomes (value, ) instead of just value. For example, converting [[1, 2], [3, 4]] results in [[(1, ), (2, )], [(3, ), (4, )]]. Using List Comprehension List comprehension provides a concise way to transform matrix elements ? def matrix_to_custom_tuple(matrix): return [[(value, ) for value in row] for row in matrix] ...

Read More

How to Set up Multiple Subplots with Group Legends using Plotly in Python

Tapas Kumar Ghosh
Tapas Kumar Ghosh
Updated on 27-Mar-2026 1K+ Views

Multiple subplots allow you to display several independent plots within a single figure for easy comparison. Plotly provides powerful tools to create subplots with shared legends, making data visualization more organized and informative. Key Functions make_subplots() Creates a grid layout for multiple plots ? from plotly.subplots import make_subplots fig = make_subplots(rows=2, cols=2, subplot_titles=("Plot 1", "Plot 2", "Plot 3", "Plot 4")) add_trace() Adds individual plot traces to specific subplot positions ? import plotly.graph_objects as go fig.add_trace(go.Scatter(x=[1, 2, 3], y=[4, 5, 6], name="Data Series"), row=1, col=1) Basic Multiple ...

Read More

Python sorted containers - An Introduction

Mrudgandha Kulkarni
Mrudgandha Kulkarni
Updated on 27-Mar-2026 1K+ Views

Python offers a wide range of data structures to efficiently organize and manipulate data. When it comes to handling sorted data, sorted containers play a crucial role. Sorted containers are data structures that maintain elements in a sorted order, providing fast access, insertion, and deletion operations. In this article, we will explore Python sorted containers and understand their significance in various applications. We will examine the different types of sorted containers and discuss their features, advantages, and implementation details. What are Sorted Containers? Sorted containers are specialized data structures that automatically maintain their elements in sorted order. ...

Read More

Python Script to Restart Computer

Mrudgandha Kulkarni
Mrudgandha Kulkarni
Updated on 27-Mar-2026 5K+ Views

Restarting a computer is a common task that we often perform to troubleshoot issues, install updates, or apply system changes. Using a Python script can provide automation and convenience for system administrators and power users. In this article, we will explore how to create a Python script that can restart a computer using the subprocess module, along with cross-platform compatibility and safety considerations. The Importance of Restarting a Computer Restarting a computer is a fundamental troubleshooting step that can help resolve various issues and improve system performance. Here are some key reasons why restarting a computer is ...

Read More

Python Script to Shutdown your PC using Voice Commands

Mrudgandha Kulkarni
Mrudgandha Kulkarni
Updated on 27-Mar-2026 605 Views

In today's world of automation and smart devices, voice control has become increasingly popular. From smartphones to virtual assistants, voice commands offer a convenient and hands−free way to interact with technology. What if you could extend this convenience to your PC as well? Imagine being able to shut down your computer with a simple voice command, saving you the trouble of manually navigating through menus or using the mouse. In this article, we will explore how to use Python to create a script that allows you to shut down your PC using voice commands. By leveraging the power of ...

Read More

Python script to shows Laptop Battery Percentage

Mrudgandha Kulkarni
Mrudgandha Kulkarni
Updated on 27-Mar-2026 1K+ Views

Monitoring your laptop's battery percentage is essential for uninterrupted usage. Python provides a simple way to create scripts that display battery information using the psutil library. This tutorial shows how to create a Python script that retrieves and displays your laptop's current battery percentage. Prerequisites Before creating the script, ensure you have the following requirements ? Python − Python 3.6 or higher installed on your system psutil Library − Install using pip with the following command ? pip install psutil The psutil library works across Windows, macOS, and Linux systems, making ...

Read More

Python Script to Open a Web Browser

Mrudgandha Kulkarni
Mrudgandha Kulkarni
Updated on 27-Mar-2026 5K+ Views

In today's digital world, web browsing has become an integral part of our daily lives. Whether it's researching information, shopping online, or accessing web-based applications, we spend a significant amount of time using web browsers. As a Python developer, wouldn't it be great to automate web browser operations and save time and effort? In this article, we'll explore how to create a Python script that opens a web browser and performs various operations. With the help of the Selenium library, we can interact with web browsers programmatically, allowing us to automate tasks such as navigating to a specific URL, ...

Read More

Python script to monitor website changes

Mrudgandha Kulkarni
Mrudgandha Kulkarni
Updated on 27-Mar-2026 4K+ Views

In today's digital age, staying up to date with the latest changes on a website is crucial for various purposes, such as tracking updates on a competitor's site, monitoring product availability, or staying informed about important information. Manually checking websites for changes can be time-consuming and inefficient. That's where automation comes in. In this tutorial, we will explore how to create a Python script to monitor website changes. By leveraging the power of Python and some handy libraries, we can automate the process of retrieving website content, comparing it with previous versions, and notifying us of any changes. ...

Read More
Showing 561–570 of 25,469 articles
« Prev 1 55 56 57 58 59 2547 Next »
Advertisements