Python Articles

Page 119 of 855

Get Month from year and weekday using Python

Asif Rahaman
Asif Rahaman
Updated on 27-Mar-2026 904 Views

Finding months that start with a specific weekday is a common task in calendar applications. Python provides several approaches using the calendar and datetime modules to determine which month in a given year starts with your desired weekday. Using the Calendar Module The calendar module provides useful functions for working with calendars and dates. It offers methods to generate calendars, calculate weekdays, and perform calendar-related operations without worrying about leap years. Example The following function iterates through all 12 months and checks which month starts with the specified weekday ? import calendar def ...

Read More

Load NumPy data in Tensorflow

Siva Sai
Siva Sai
Updated on 27-Mar-2026 550 Views

TensorFlow provides seamless integration with NumPy arrays through the tf.data.Dataset.from_tensor_slices() function. This allows you to convert NumPy arrays into TensorFlow datasets, enabling efficient data processing and model training. Prerequisites Make sure that your Python environment has NumPy and TensorFlow installed − pip install numpy tensorflow Basic NumPy Array Loading The simplest way to load NumPy data into TensorFlow is using tf.data.Dataset.from_tensor_slices() ? import numpy as np import tensorflow as tf # Create a NumPy array numpy_data = np.array([1, 2, 3, 4, 5]) # Load the NumPy data into TensorFlow ...

Read More

Load CSV data into List and Dictionary using Python

Siva Sai
Siva Sai
Updated on 27-Mar-2026 6K+ Views

CSV (Comma-Separated Values) files are widely used for data exchange between applications. Python's built-in csv module makes it easy to read CSV data into lists and dictionaries for further processing and analysis. This article demonstrates how to load CSV data into Python's most commonly used data structures with practical examples. Sample CSV Data For our examples, we'll use a sample CSV file with the following data ? Name, Age, Country Alice, 25, USA Bob, 30, UK Charlie, 35, Canada Loading CSV Data into a List The csv.reader() function reads CSV data and ...

Read More

llist module in Python

Siva Sai
Siva Sai
Updated on 27-Mar-2026 329 Views

The llist module provides efficient linked list data structures for Python. Unlike Python's built-in lists, linked lists excel at insertions and deletions in large datasets by avoiding the need to shift elements. Installation Install the llist module using pip − pip install llist Singly Linked List (sllist) A singly linked list where each node points to the next node. Here's how to create and manipulate one − from llist import sllist # Create a singly linked list sll = sllist() # Add elements sll.append('Python') sll.append('Java') sll.append('JavaScript') print(sll) ...

Read More

List all the Microphones connected to System in Python using PyAudio

Siva Sai
Siva Sai
Updated on 27-Mar-2026 4K+ Views

PyAudio is a powerful Python library that provides bindings for PortAudio, enabling audio input/output operations across multiple platforms. One common requirement when working with audio applications is identifying and listing all available microphones connected to the system. Installation Before using PyAudio, install it using pip − pip install pyaudio For Jupyter notebooks, use − !pip install pyaudio Getting Device Count First, let's check how many audio devices are connected to your system − import pyaudio # Create PyAudio instance p = pyaudio.PyAudio() # Get total ...

Read More

Get Hardware and System information using the Python Platform Module.

Asif Rahaman
Asif Rahaman
Updated on 27-Mar-2026 977 Views

Python is a versatile language that was built as a general-purpose scripting language. Hence a lot of automation tasks, along with scripting, can be done. Getting the system information becomes an important task in many applications such as machine learning, deep learning, etc., where hardware plays a crucial role. Python provides several methods to gather information about the operating system and hardware. Getting Overall System Configuration The platform module in Python provides a way to obtain the overall system configuration in a platform-independent manner. So we can run the same methods to get the system configuration without knowing ...

Read More

List all files of certain type in a directory using Python

Siva Sai
Siva Sai
Updated on 27-Mar-2026 2K+ Views

Python's flexible features and strong libraries make manipulating files and directories a breeze. One common requirement is listing all files of a specific type in a directory. This tutorial will walk you through various approaches using real-world examples to demonstrate Python's proficiency with filesystem operations. Introduction to Python's Os and Glob Libraries The standard Python library includes several modules for filesystem operations. The os and glob modules are two powerful options: os module − Provides tools for communicating with the operating system, including operations for creating, deleting, and browsing directories. glob module − Uses Unix shell-style ...

Read More

Get Confirmed, Recovered, Deaths cases of Corona around the globe using Python

Asif Rahaman
Asif Rahaman
Updated on 27-Mar-2026 167 Views

The COVID-19 pandemic has impacted billions of lives worldwide, creating widespread concern among people. Several applications were built to track and analyze accurate information about deaths, recovered cases, and confirmed cases. Fetching and analyzing this information is crucial for developers building pandemic-related applications. In this article, we will explore three different methods to retrieve statistical data about COVID-19 cases using Python. Method 1: Using APIs APIs (Application Programming Interfaces) enable software applications to interact with each other by defining protocols for data exchange and functionality access. Web APIs, often based on HTTP, allow developers to access data and ...

Read More

Linked list using dstructure library in Python

Siva Sai
Siva Sai
Updated on 27-Mar-2026 262 Views

The Dstructure library in Python provides efficient tools for implementing various data structures including linked lists. This library simplifies the creation and manipulation of linked lists with easy-to-use methods for common operations. We'll explore how to create and work with linked lists using the Python Dstructure library, covering essential operations from basic creation to advanced manipulations. What is a Linked List? A linked list is a linear data structure where elements are not stored in consecutive memory locations. Instead, each node contains data and a pointer to the next node. This structure allows for dynamic memory allocation ...

Read More

linecache.getline() in Python

Siva Sai
Siva Sai
Updated on 27-Mar-2026 788 Views

The linecache module in Python provides an efficient way to read specific lines from files. The linecache.getline() function retrieves a single line from any file while automatically handling caching for improved performance on subsequent reads. Syntax linecache.getline(filename, lineno, module_globals=None) Parameters filename − Path to the file to read from lineno − Line number to retrieve (1-based indexing) module_globals − Optional global namespace for module files Basic Example Let's create a simple text file and retrieve a specific line ? import linecache # Create sample content (simulating test.txt) ...

Read More
Showing 1181–1190 of 8,546 articles
« Prev 1 117 118 119 120 121 855 Next »
Advertisements