Found 11040 Articles for Python

NZEC error in Python?

Arjun Thakur
Updated on 30-Jul-2019 22:30:26

521 Views

NZEC is non-zero exit code.Exit codes are codes (number) return by running program to operating system upon either their successfully termination (Exit code 0) or failed termination due to error (Non zero exit code).As python or Java programming language supports exception handling, we can use exception handling using try-catch blocks to catch this error.NZEC error is a runtime error and occurs mostly when negative array index is accesed or the program which we have written is utilizing more memory space than the allocated memory for our program to run.In python Exception class is the super class of all the errors ... Read More

Line detection in python with OpenCV?

Ankith Reddy
Updated on 30-Jul-2019 22:30:26

2K+ Views

In this post, we are going to learn, how to detect lines in an image, with the help of a technique called Hough transform.Hough transform?Hough transform is a feature extraction method to detect any simple shape, if you can represent that shape in mathematical form. It somehow manage to detect the shape even if it is broken or distorted a little bit. We will see how it works for a line.A “simple” shape is one that can be represented by only a few parameters. For example, a line can be represented by two parameters only (slope, intercept) and a circle ... Read More

Packaging and Publishing Python code?

George John
Updated on 30-Jul-2019 22:30:26

119 Views

Python provides a very simple way of creating or publishing packages.Package management in Python is available through different tools−Pip- It remains one of the preferred choices because it virtually eliminates any manual installs and updates of software packages to operating systems. It manages full lists of packages and their corresponding version numbers, which fosters precise duplication of entire package groups in a distinct, separate environment.Python Package Index (PPI) is a public package repository of user-submitted packages that can be installed using pip .i.e. pip install package_name.Below is a step-by-step procedure on how to upload the package.Step 1: Have a package ... Read More

Mouse and keyboard automation using Python?

Chandu yadav
Updated on 30-Jul-2019 22:30:26

1K+ Views

In this section, we’ll try to automate the movements of mouse and keyboard using pyautogui module in python.Pyautogui is a library that allows you to control the mouse and keyboard to do various things.It  is a cross-platform GUI automation Python module for human beings.As it is a third party library, we need to install it.pip install pyautoguiMouseBelow is program to automate the movement of your mouse. On running your programme, you can see the mouse movement with every command. I run below command on CLI so as to capture the mouse movement. You can try with others different values too.Example>>> ... Read More

Using OpenCV in Python to Cartoonize an Image

Arjun Thakur
Updated on 31-Mar-2023 15:38:22

515 Views

Currently there are lots of professional cartoonizer applications available in the market but most of the them are not freeware. In order to get the basic cartoon effect, we just need the bilateral filter and some edge dectection mechanism. The bilateral filter will reduce the color palette, which is essential for the cartoon look and edge detection is to produce bold silhouettes.We are going to use openCV python library to convert an RGB color image to a cartoon image.AlgorithmFirstly apply the bilateral filter to reduce the color palette of the image.Then conver the actual image to grayscale.Now apply the median ... Read More

OpenCV Python Program to blur an image?

Ankith Reddy
Updated on 30-Jul-2019 22:30:26

337 Views

OpenCV is one of the best python package for image processing. Also like signals carry noise attached to it, images too contain different types of noise mainly from the source itself (Camera sensor). Python OpenCV package provides ways for image smoothing also called blurring. This is what we are going to do in this section. One of the common technique is using Gaussian filter (Gf) for image blurring. With this, any sharp edges in images are smoothed while minimizing too much blurring.Syntaxcv.GaussianBlur(src,  ksize,  sigmaX[,  dst[,  sigmaY[,  borderType=BORDER_DEFAULT]]] )Where−src – input imagedst – output imageksize – Gaussian kernel size[ height width]. If ksize ... Read More

Object Oriented Programming in Python?

George John
Updated on 30-Jul-2019 22:30:26

928 Views

Python has been an object oriented programming language since its existence. Classes and objects are the two main building blocks of object oriented programming.A class creates a new type of objects where objects are instances of the class.Let’s create one of the simplest class, Define a class in PythonLet just define an empty class.#Define a class class Vehicle():    pass # An empty block # Instantiating objects v = Vehicle() print(v)ResultWhat we have done above?So first, we use class statement to create new class Vehicle, which is followed by an indented block of statements which form the body of ... Read More

Permutation and Combination in Python?

Chandu yadav
Updated on 30-Jul-2019 22:30:26

697 Views

In this section, we are going to learn how to find permutation and combination of a given sequence using python programming language.One of the key advantage of python over other programming language is that it comes with huge set of libraries with it.We are going to use python inbuilt package to find permutation and combinations of a given sequence.Algorithm to find the Permutation and combinationStep 1 : Import required package. First step is to import the required package, as we are going to use itertools package, so we just import it using.>>> import itertools >>>Step 2: Get all permutation & combination ... Read More

Python program to Rearrange a string so that all same characters become d distance away

Arjun Thakur
Updated on 30-Jul-2019 22:30:26

599 Views

Given a non-empty string str and an integer k , rearrange the string such that the same characters are at least distance k from each other.All input strings are given in lowercase letters. If it is not possible to rearrange the string, return an empty string "".Example 1:str = “tutorialspoint”, k = 3 Answer: “tiotiotalnprsu”The same characters are at least 3 character distance apart.str = "aabbcc", k = 3 Answer: "abcabc" The same characters are at least 3 character distance apart.Example 2str = "aaabc", k = 3 Answer: "" It is not possible to rearrange the string.Example 3:str = "aaadbbcc", k = ... Read More

Python program to Find the first non-repeating character from a stream of characters?

AmitDiwan
Updated on 11-Aug-2022 11:57:47

6K+ Views

In this article, we will find the first non-repeating character from a stream of character. Let’s say the following is our input − Thisisit The following should be our output displaying first non-repeating character − H Find the first non-repeating character from a stream of characters using while loop We will find the first non-repeating character, by comparing each character with the other using a loop − Example # String myStr = "thisisit" # Looping while myStr != "": slen0 = len(myStr) ch = myStr[0] myStr = myStr.replace(ch, "") slen1 = len(myStr) if slen1 == slen0-1: print ... Read More

Advertisements