Server Side Programming Articles

Page 102 of 2109

How to Get the First Element in List of Tuples in Python?

Asif Rahaman
Asif Rahaman
Updated on 27-Mar-2026 2K+ Views

When working with a list of tuples in Python, extracting the first element from each tuple is a common task. Python provides several approaches including loops, list comprehension, map() function, unpacking, and the zip() method. Using For Loop A simple loop iterates through each tuple and accesses the first element using index [0] − def get_first_element_using_loop(tuples_list): first_elements = [] for item in tuples_list: first_elements.append(item[0]) return first_elements fruits = [ ('Apple', 5, ...

Read More

Get the List of Files in a Directory Sorted by Size Using Python.

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

Getting a list of files in a directory sorted by size is a common task in Python file operations. Python provides several approaches using the os module, glob module, and sorting techniques like lambda functions and the operator module. Using os.listdir() with Operator Module The os module provides functions to interact with the operating system, while the operator module offers built-in operators for cleaner code ? import os import operator # Create sample files for demonstration os.makedirs('files', exist_ok=True) with open('files/small.txt', 'w') as f: f.write('Small file') with open('files/medium.txt', 'w') as f: ...

Read More

Load Text in Tensorflow

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

TensorFlow is a powerful open-source framework developed by Google that excels at handling various types of data, including text. Loading and processing text data efficiently is crucial for natural language processing tasks like sentiment analysis, text classification, and language translation. Understanding Text Data in TensorFlow Text data is unstructured and requires special handling before it can be used in machine learning models. TensorFlow provides the tf.data API with specialized classes like TextLineDataset to streamline text data loading and preprocessing operations. Installing TensorFlow Before working with text data, ensure TensorFlow is installed ? pip install ...

Read More

Load Testing Using LOCUST

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

Load testing is essential for evaluating application performance under real-world conditions. Locust is a powerful, open-source Python tool that allows you to simulate thousands of concurrent users and define user behavior using Python code. This guide will walk you through load testing fundamentals with practical Locust examples. What is Locust? Locust is a distributed, scalable load testing framework that helps engineers understand how many concurrent users their system can handle. Its key advantage is using Python code to describe user behavior, making it extremely flexible and customizable for complex testing scenarios. Installing Locust Before installing Locust, ...

Read More

Get Month from year and weekday using Python

Asif Rahaman
Asif Rahaman
Updated on 27-Mar-2026 897 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 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 970 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
Showing 1011–1020 of 21,090 articles
« Prev 1 100 101 102 103 104 2109 Next »
Advertisements