Niharika Aitam

Niharika Aitam

133 Articles Published

Articles by Niharika Aitam

Page 7 of 14

How to check if an object is iterable in Python?

Niharika Aitam
Niharika Aitam
Updated on 27-Mar-2026 1K+ Views

An iterable object is any object that can be iterated through all its elements using a loop or iterable function. Lists, strings, dictionaries, tuples, and sets are all iterable objects in Python. There are several reliable methods to check if an object is iterable. Let's explore the most effective approaches. Using try-except with iter() The most Pythonic way is to use iter() function inside a try-except block. This approach follows the "easier to ask for forgiveness than permission" (EAFP) principle ? # Check if a list is iterable data = ["apple", 22, "orange", 34, "abc", ...

Read More

How to check if an application is open in Python?

Niharika Aitam
Niharika Aitam
Updated on 27-Mar-2026 6K+ Views

A process is a program under execution. When an application runs on your operating system, it creates one or more processes. Python provides several methods to check if a specific application is currently running on your system. We'll explore three different approaches to check if an application is open: using the psutil module, the subprocess module, and the wmi module for Windows systems. Using psutil.process_iter() Function The psutil module provides a cross-platform interface for retrieving information about running processes and system utilization. It works on Linux, Windows, macOS, Solaris, and AIX. First, install psutil using ? ...

Read More

How to check the file size?

Niharika Aitam
Niharika Aitam
Updated on 27-Mar-2026 657 Views

Files are used to store certain data based on user requirement. A file can contain any type of information such as audio, text, images, video or program. Depending on the data present in a file, the size of a file varies. The size of a file is measured in bits or bytes. A bit is the smallest unit of information which is typically represented by a single value: either 0 or 1. Bytes are used to measure the amount of data in a file and the bytes are denoted by 8 bits. There are several ways to check the ...

Read More

How to check Django version?

Niharika Aitam
Niharika Aitam
Updated on 27-Mar-2026 1K+ Views

Django is a free, open source web framework written in Python that follows the Model-View-Controller (MVC) architectural pattern. It's designed to help developers build web applications quickly and efficiently with minimal complexity. The key features of the Django framework include: Object-Relational Mapper (ORM) for database management URL routing and HTTP request/response handling Template engines for generating HTML pages Built-in user authentication and administration Support for third-party modules and packages Community support and comprehensive documentation Django is widely used by organizations like Google, Pinterest, Mozilla, and Instagram for building scalable and robust web applications. Installing ...

Read More

How to check any script is running in linux using Python?

Niharika Aitam
Niharika Aitam
Updated on 27-Mar-2026 5K+ Views

The psutil module in Python helps us retrieve information about processes currently running on our Linux system. This is essential for monitoring and managing scripts programmatically. What is a Script? A script is a set of instructions written in a programming language and executed by the computer. Scripts help us perform repetitive tasks efficiently, from simple file operations to complex system administration. In Linux, scripts are typically executed through command line using shell interpreters like Bash or Python interpreters. These scripts can be scheduled using cron or systemd timers. Method 1: Using psutil Module The psutil ...

Read More

How to change ticks label sizes using Python’s Bokeh

Niharika Aitam
Niharika Aitam
Updated on 27-Mar-2026 291 Views

Bokeh is a powerful Python data visualization library that creates interactive plots and dashboards for web browsers. When working with Bokeh plots, you may need to customize the tick label sizes to improve readability and visual appeal. This article demonstrates how to change tick label sizes using various Bokeh formatting options. Understanding Tick Labels in Bokeh Tick labels are the text labels that appear along the axes of a plot, indicating the values at specific tick marks. In Bokeh, you can customize these labels using the axis properties and formatting options. Installing Bokeh First, install the ...

Read More

How to change the PyGame icon?

Niharika Aitam
Niharika Aitam
Updated on 27-Mar-2026 2K+ Views

While building video games, we often want to set a custom image or logo for the developed game. Python's Pygame library provides the set_icon() function to set a custom window icon. Pygame is a set of modules that allows us to develop games and multimedia applications. This is built on top of the SDL (Simple Direct Media Layer) library which provides low-level access to audio, keyboard, mouse, joystick, and graphics hardware through OpenGL and Direct3D. Syntax Following is the syntax for setting the icon for the game ? pygame_icon = pygame.image.load("image_name") pygame.display.set_icon(pygame_icon) Where, ...

Read More

How to change the position of legend in Pygal?

Niharika Aitam
Niharika Aitam
Updated on 27-Mar-2026 252 Views

Pygal is a Python data visualization library designed to create interactive charts and graphs. Built with advanced SVG (Scalable Vector Graphics) features, it produces high-quality graphics that can be easily embedded into web pages and applications. Installing Pygal You can install Pygal using pip ? pip install pygal Understanding Legends in Pygal The legend adds context and clarity to charts by displaying the names of each data series and their corresponding colors. By default, legends appear at the top of Pygal charts. Changing Legend Position Syntax To change the legend ...

Read More

Compute the outer product of two given vectors using NumPy in Python

Niharika Aitam
Niharika Aitam
Updated on 27-Mar-2026 418 Views

The outer product of two vectors is a matrix obtained by multiplying each element of the first vector with each element of the second vector. In NumPy, the outer product of vectors a and b is denoted as a ⊗ b. Outer Product Formula: a = [a₀, a₁, a₂, ...] b = [b₀, b₁, b₂, ...] a ⊗ b = a₀×b₀ a₀×b₁ a₀×b₂ a₁×b₀ a₁×b₁ a₁×b₂ a₂×b₀ a₂×b₁ a₂×b₂ ...

Read More

Python - Chuncked summation every K value

Niharika Aitam
Niharika Aitam
Updated on 27-Mar-2026 321 Views

Chunked summation, also known as partial sum or rolling sum, is a process of calculating the sum of elements in smaller chunks or subsets rather than processing the entire sequence at once. Each chunk represents a group of consecutive elements from the sequence, and the sum is calculated for each chunk individually. For example, consider the sequence [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], and let's calculate the chunked sum with a chunk size of 3 ? Chunk 1: [1, 2, 3] → Sum: 1 + 2 + 3 = ...

Read More
Showing 61–70 of 133 articles
« Prev 1 5 6 7 8 9 14 Next »
Advertisements