Pranay Arora

Pranay Arora

36 Articles Published

Articles by Pranay Arora

Page 3 of 4

How to Delete the True Values in a Python List?

Pranay Arora
Pranay Arora
Updated on 27-Mar-2026 475 Views

In Python, lists are one of the most commonly used data structures that allow us to store various elements. Sometimes, we may encounter situations where we need to remove specific boolean values from a list. In this article, we will explore six different methods to remove True values from a Python list. Problem Statement Consider a list containing a mixture of boolean values and other data types, and we need to remove all occurrences of True from that list. Let's see an example ? Input: sample_list = [True, 2, False, True, 4, True, 6, True] ...

Read More

How to Convert Dictionary values to Absolute Magnitude using Python?

Pranay Arora
Pranay Arora
Updated on 27-Mar-2026 395 Views

Converting dictionary values to their absolute magnitude means transforming negative values to positive while keeping positive values unchanged. Python provides several approaches to achieve this transformation using the built-in abs() function. Understanding the abs() Function The abs() function returns the absolute value of a number. For real numbers, it returns the positive value. For complex numbers, it returns the magnitude. # Basic abs() usage print(abs(-5)) # Positive number print(abs(5)) # Already positive print(abs(-3.14)) # Float number 5 5 3.14 Method 1: Using For Loop ...

Read More

How to Convert dictionary to K sized dictionaries using Python?

Pranay Arora
Pranay Arora
Updated on 27-Mar-2026 181 Views

Dictionaries are key-value data structures in Python where the keys are unique and values can be repeated. In this article, we will explore how to convert a dictionary into K smaller dictionaries by distributing key-value pairs evenly across K separate dictionaries. Problem Example Given a dictionary with 9 key-value pairs: original_dict = {'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5, 'f': 6, 'g': 7, 'x': 8, 'y': 9} k = 3 # Expected output: 3 dictionaries with distributed pairs # [{'a': 1, 'd': 4, 'g': 7}, {'b': 2, 'e': 5, 'x': 8}, {'c': ...

Read More

How to Convert Dictionary to Concatenated String using Python?

Pranay Arora
Pranay Arora
Updated on 27-Mar-2026 518 Views

A dictionary in Python is a built-in data structure that allows you to store and retrieve values using unique keys. Converting a dictionary to a concatenated string means combining all keys and values into a single string without separators. For example ? Input = {'one': 1, 'two': 2, 'three': 3} Output = one1two2three3 Let's explore different methods to achieve this conversion. Using a Loop and F-string This method iterates through the dictionary's key-value pairs and concatenates them using an f-string ? dictionary = {'one': 1, 'two': 2, 'three': 3} concatenated_string = ...

Read More

Convert Image to String and vice-versa in Python

Pranay Arora
Pranay Arora
Updated on 27-Mar-2026 4K+ Views

Converting images to string format and back is a common requirement in Python applications. This process involves encoding image binary data into text format for storage, transmission, or processing, then decoding it back to reconstruct the original image. Converting Image to String − This involves transcribing binary image data into text format using encoding schemes like Base64. This conversion is useful for transmitting images through APIs, storing in databases, or sending over text-based protocols. Converting String to Image − This reverses the process by decoding the encoded string back into binary data to reconstruct the original image file. ...

Read More

How to Create Custom Turtle shapes in Python?

Pranay Arora
Pranay Arora
Updated on 27-Mar-2026 4K+ Views

Python's Turtle library is used for generating 2D graphics and animations. It has a very simple interface with help of which we can create shapes and patterns on the screen. It comes with some built-in shapes like squares, circles, triangles etc. However, we can even create our own shapes with the help of Turtle. In this article, we are going to see how to create custom turtle shapes in python. Before going forward with the creating custom shapes we need to install Turtle on the system and this can be done by simply using the following command − ...

Read More

How to Create Bottom Navigation using Kivymd and Python?

Pranay Arora
Pranay Arora
Updated on 27-Mar-2026 754 Views

KivyMD is a commonly known library of Python which offers us with a collection of Material Design (MD) compliant widgets. These widgets can be used along with the kivy framework which is another library and is used for creating multi-touch applications. The large number of UI elements that kivyMD provides us with, include buttons, cards, dialogs, menus and many more such elements, all of which are designed to give an appealing look and feel. A navigation bar is a UI element that allows users to "navigate" between different screens/sections of an application. They are normally present on the top ...

Read More

Insert a character after every n characters in JavaScript

Pranay Arora
Pranay Arora
Updated on 15-Mar-2026 5K+ Views

Insertion of a specific character after every n characters in JavaScript is an easy-to-understand concept that gives us better understanding of JavaScript's string manipulation functions. Here n can be any whole number ranging from 1 to less than the length of the string. In this article, we'll explore different methods to insert a "-" character after every 5 characters in a string. Method 1: Using the slice() Method The slice() method extracts a portion of a string and returns a new string. It accepts two parameters: the starting index and the ending index (exclusive). let ...

Read More

Java program to demonstrate the call by value

Pranay Arora
Pranay Arora
Updated on 11-Nov-2024 975 Views

In programming, functions often require parameters to be passed to them to be called or invoked. There are 2 ways to call functions, the 1st being call by Reference and the 2nd being call by value. In this article, we are going to demonstrate call by value in Java. Call by value is a method in which the value of the argument is passed as a copy to the function, hence any change made to this argument inside the function will not affect the original value of the argument beyond the scope of this function. To help understand these concepts ...

Read More

Java program to display Floyd\'s triangle

Pranay Arora
Pranay Arora
Updated on 18-Oct-2024 1K+ Views

In this article, we are going to see how to display Floyd’s Triangle using Java. Floyd's triangle is a popular right-angled triangular array consisting of natural numbers. It is formed by starting with the number 1 at the top of the triangle, and then incrementing each subsequent number by 1 as you move down the rows of the triangle. The first row contains only 1 number which is 1 itself and each subsequent row contains 1 more number than the previous row. The triangle has n rows where n can be any positive whole number. The total number of values in ...

Read More
Showing 21–30 of 36 articles
Advertisements