Found 34484 Articles for Programming

Image Segmentation in OpenCV Python with Watershed Algorithm

Prince Yadav
Updated on 25-Jul-2023 13:29:25

1K+ Views

As passionate computer vision enthusiasts and Python programmers, we have always been captivated by the incredible capabilities of the OpenCV library. One technique that has particularly fascinated us is image segmentation, the process of dividing an image into distinct regions. This article will share our journey and insights on performing image segmentation using OpenCV Python with the Watershed algorithm. By leveraging the concept of water flow in a physical landscape, the Watershed algorithm has emerged as a powerful tool for accurately identifying boundaries and separating objects in an image. Together, we will dive into the step−by−step process, from preprocessing the ... Read More

How to use if, else & elif in Python Lambda Functions

Prince Yadav
Updated on 25-Jul-2023 13:27:20

3K+ Views

Python is a versatile and powerful programming language known for its simplicity and readability. One of the key features that make Python stand out is its support for lambda functions, which are anonymous functions that can be created on the fly. Lambda functions offer a concise and elegant way to define small, one−line functions without the need for a formal function definition. These functions can be used in various scenarios to enhance code readability and maintainability. In this tutorial, we will delve into the fascinating world of lambda functions in Python and explore how to incorporate if, else, and elif ... Read More

How To Process Incoming Request Data in Flask

Prince Yadav
Updated on 25-Jul-2023 13:23:20

247 Views

Efficiently processing incoming request data is an important aspect of web development, and Flask offers developers an intuitive solution for handling and managing client−sent data. As a widely−used micro web framework for Python, Flask simplifies the entire process, whether it involves form submissions, AJAX requests, or API calls. Leveraging the powerful features of Flask, developers can effortlessly access and process diverse types of incoming data, including form data, JSON payloads, and query parameters. This article divides into a comprehensive exploration of various techniques and provides practical examples to effectively handle incoming request data in Flask. From leveraging the request ... Read More

How to Create a new project in Django using Firebase Database?

Prince Yadav
Updated on 25-Jul-2023 13:18:51

2K+ Views

Django, a powerful and popular Python web framework, has revolutionized the way developers create dynamic web applications. With its robust features and ease of use, Django has become a go−to choice for building scalable and secure websites. On the other hand, Firebase, a cloud−based platform provided by Google, offers a comprehensive suite of tools for app development, including real−time databases, authentication, and hosting. In this tutorial, we will explore how to create a new project in Django using Firebase as the database. We'll dive into the step−by−step process of setting up the development environment, configuring Django to work with ... Read More

How to create a list of objects in the Python class

Prince Yadav
Updated on 25-Jul-2023 13:13:08

5K+ Views

Python is a dynamic and skilled programming language that supports object−oriented programming (OOP). At the heart of OOP is the concept of objects, which are instances of a class. Classes in Python serve as blueprints for creating objects with specific attributes and methods. One common use case in OOP is to create a list of objects, where each object represents a unique instance of the class. In this article, we will talk about the process of creating a list of objects within a Python class. We will discuss the essential steps involved, including defining a class, creating objects of that ... Read More

How to Create a list of files, folders, and subfolders in Excel using Python?

Prince Yadav
Updated on 25-Jul-2023 13:03:14

558 Views

Python is a great programming language widely used for various data manipulation tasks. When working with files and folders, it can be useful to generate a list of all the files, folders, and subfolders within a directory. Excel, on the other hand, is a popular spreadsheet application that allows users to organize and analyze data. In this detailed article, we will explore step−by−step how to use Python to create a comprehensive list of files, folders, and subfolders in Excel, providing a convenient way to manage and analyze file structures. So make sure to stick with this till the end. Prerequisites ... Read More

Minimum characters to be replaced in Ternary string to remove all palindromic substrings for Q queries

Prabhdeep Singh
Updated on 26-Jul-2023 10:51:57

84 Views

A palindromic string is a string that is equal to its reverse string. We are given a string that contains ‘0’, ‘1’, and ‘2’ and an array Q of length N and each index of the given array indicates a range in the form of pairs. We have to find the minimum number of characters that are needed to replace in the given range such that none of the palindromic substrings remains in that range. Sample Example Input1: string s: “01001020002”, int Q = {{0, 4}, {2, 5}, {5, 10}}; Output: 1 1 3 Explanation For the range ... Read More

Maximize given function by selecting equal length substrings from given Binary Strings

Prabhdeep Singh
Updated on 26-Jul-2023 10:50:29

120 Views

Two binary strings str1 and str2 of the same length are given and we have to maximize a given function value by choosing the substrings from the given strings of equal length. The given function is such that − fun(str1, str2) = (len(substring))/(2^xor(sub1, sub2)). Here, len(substring) is the length of the first substring while xor(sub1, sub2) is the xor of the given substrings as they are binary strings so it is possible. Sample Examples Input1: string str1 = 10110 & string str2 = 11101 Output: 3 Explanation We can choose a lot of different sets of strings ... Read More

Minimum number of adjacent swaps to reverse a String

Prabhdeep Singh
Updated on 26-Jul-2023 10:42:32

346 Views

A string str is given and we can swap only adjacent characters to make the string reverse. We have to find the number of minimum moves required to make the string reverse just by swapping the adjacent characters. We will implement two approaches to find the required solution with the explanation and the implementation of the code. Sample Examples Input1: string str1 = “shkej” Output: 10 Explanation First, we will take the last character to the first position which will take 4 swappings, and then the string will be “jshke”. Then we will move ‘e’ to the second ... Read More

Minimum count of prefixes and suffixes of a string required to form a given string

Prabhdeep Singh
Updated on 26-Jul-2023 10:40:31

251 Views

Prefixes are the substring from the given string that starts from the zeroth index and can go up to length 1 to the size of the string. Similarly, the suffix is the substring of any length 1 to the size of the string and ends at the last index. We will be given two strings and have to create the first string by using any number of prefixes and suffixes of the second string in any way. If it is not possible to create the given string from the given methods then we will return -1. Sample Examples Input 1: ... Read More

Advertisements