Found 33676 Articles for Programming

Sort on the basis of number of factors using STL

Eva Sharma
Updated on 16-Aug-2023 10:50:58

199 Views

Sorting a vector using STL is a piece of cake. We can use the famous sort() function to perform the task. The real challenge is to count the number of factors for each number. A factor is a number which divides another number completely, i.e. with zero remainder. Traversing through all the numbers to count the factors might be an approach but we will try to optimize and reach efficient solutions in this article. Problem Statement Sort a given array based on the number of factors of each number in increasing order. Thus, the number having the lowest number of ... Read More

P-Smooth Numbers or P-friable Number

Eva Sharma
Updated on 16-Aug-2023 10:47:44

224 Views

A number is p-friable for p-smooth if all of its prime factors are less than or equal to p. For example, 1620 is a 5-smooth number. Because, the prime factors of 1620 are: 2, 3, and 5. As it can be seen, 1620 is also a 7-smooth and 11-smooth number. Problem Statement Given two numbers N and P, we have to check if N is a P-friable number or not. Examples Input − N = 50, P = 7 Output − Yes, 50 is a 7-friable number. Explanation 50 can be prime factorized as: 5*5*5*5. Hence, ... Read More

Adding double tap on any widget in Python Kivy

Priya Sharma
Updated on 14-Aug-2023 14:11:23

424 Views

Python Kivy is a powerful framework for building multi-touch applications, allowing developers to create interactive and intuitive user interfaces. One common requirement in many applications is the ability to detect and respond to double tap gestures on specific widgets. Setting up the Kivy Application Before diving into the implementation of double tap functionality, we need to set up a basic Kivy application. This step provides a foundation for the subsequent code implementation. We start by creating a new Python file and importing the necessary modules from the Kivy framework − from kivy.app import App from kivy.uix.boxlayout import BoxLayout from ... Read More

Adding custom dimension in Matrix using Python

Priya Sharma
Updated on 14-Aug-2023 14:29:59

323 Views

Matrices are fundamental data structures in linear algebra and are extensively used in various scientific and mathematical computations. A matrix is a rectangular array of numbers arranged in rows and columns. It is commonly represented as a two-dimensional grid. However, there are scenarios where we may need to manipulate matrices with additional dimensions, either for data transformation or to perform advanced mathematical operations. Python, being a versatile programming language, offers a rich ecosystem of libraries that provide powerful tools for matrix operations. One such library is NumPy, which stands for Numerical Python. NumPy provides efficient and convenient tools for working ... Read More

Adding Custom Column to Tuple list in Python

Disha Verma
Updated on 13-Jul-2025 00:27:19

421 Views

In this article, we will learn how to add a custom column in a tuple list (i.e., a list of tuples) in Python. Tuples store sequences of data enclosed in parentheses as shown below: Tuples = (11, 22, 33) And the list of tuples is represented as follows: List of tuples = [(11, 22, 33), (44, 55, 66), (77, 88, 99)] Suppose we have a list called "students" that stores student data (i.e., name, age) as tuples. If we represent it in the form of rows and columns, the first element of the tuples ... Read More

Adding a prefix to each key name in a Python dictionary

Priya Sharma
Updated on 22-Sep-2025 16:18:38

674 Views

In this article, we will understand how to add a prefix to each key name in a Python dictionary. Dictionaries in Python are collections of unordered items stored in the form of key-value pairs inside curly braces like this − Dictionary = {key: value, ….} Our goal is to add a prefix (i.e., a word or character added at the beginning of another word) to each key name of the dictionary in Python. Suppose a key in a dictionary is "name", on adding the prefix "company_" to it, the key becomes "company_name". For example − #Input dictionary: Dictionary = ... Read More

Add K to Minimum element in Column Tuple List in Python

Priya Sharma
Updated on 14-Aug-2023 14:37:07

118 Views

Working with datasets involves identifying the smallest value in a specific column and updating it by adding a constant value (K). By implementing an optimized solution, we can efficiently perform this operation, which is crucial for data manipulation and analysis tasks. Working with tuple lists is a common way to represent structured data, where each tuple corresponds to a row and contains multiple elements or attributes. In this case, we will focus on a specific column of the tuple list and target the minimum element within that column. Understanding the Problem Before looking at the solution, let's establish a ... Read More

Adaptive Blur using Python Wand

Priya Sharma
Updated on 14-Aug-2023 14:37:39

265 Views

Image blurring is a fundamental technique in image processing that helps reduce noise and smooth out details. While traditional blur operations apply the same level of blurring uniformly across the entire image, adaptive blur takes it a step further by allowing variable blurring levels based on local image features. This enables us to preserve important details while effectively reducing noise and enhancing image quality. In this blog post, we'll explore how to implement adaptive blur using Python Wand, a powerful Python library for image manipulation. Python Wand provides a simple and intuitive interface for working with images and offers a ... Read More

Absolute Tuple Summation in Python

Priya Sharma
Updated on 14-Aug-2023 14:38:27

357 Views

In Python, tuples are immutable sequences that can store multiple elements of different types. They are often used to represent collections of related values. Tuple summation involves adding the corresponding elements of two or more tuples to produce a new tuple. However, in some scenarios, it may be necessary to compute the absolute sum of the elements rather than the traditional sum. In this blog post, we will explore how to perform absolute tuple summation in Python. Traditional Tuple Summation Before diving into absolute tuple summation, let's first understand how to perform traditional tuple summation. Given two tuples of the ... Read More

Treeview Scrollbar in Python-Tkinter

Priya Sharma
Updated on 14-Aug-2023 14:39:51

6K+ Views

When working with hierarchical data in graphical user interfaces (GUIs), it's often necessary to display the data in a structured and organized manner. The Treeview widget in Python-Tkinter provides a powerful solution for presenting hierarchical data in a user-friendly way. However, as the number of items in the Treeview grows, it becomes crucial to include a scrollbar to ensure smooth navigation and usability. Firstly, ensure that you have Python and Tkinter installed on your system. Python 3 is recommended for compatibility and improved features. If you don't have Tkinter installed, you can easily install it using pip, the Python package ... Read More

Advertisements