Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Programming Articles - Page 2460 of 3366
367 Views
In this article, we will learn about K’th Non-repeating Character in Python using List Comprehension and OrderedDict. To do so we take the help of inbuilt constructs available in Python.Algorithm1. First, we form a dictionary data from the input. 2. Now we count the frequency of each character. 3. Now we extract the list of all keys whose value equals 1. 4. Finally, we return k-1 character.Examplefrom collections import OrderedDict import itertools def kthRepeating(inp, k): # returns a dictionary data dict=OrderedDict.fromkeys(inp, 0) # frequency of each character for ch in inp: ... Read More
380 Views
In this article, we will learn about the four iterator functions available in Python 3.x. Or earlier namely accumulate() , chain(), filter false() , dropwhile() methods.Now let’s look on each of them in detail −Accumulate () & chain() methodAccumulate() method takes two arguments, one being iterable to operate on and another the function/operation to be performed. By default, the second argument performs the addition operation.Chain() method prints all the iterable targets after concatenating all of the iterables.The below example explains the implementation −Example Live Demoimport itertools import operator as op # initializing list 1 li1 = ['t', 'u', 't', 'o', 'r'] ... Read More
300 Views
In this article, we will learn about convolutions in Python 3.x. Or earlier. This articles come under neural networks and feature extraction.Ide preferred − Jupyter notebookPrerequisites − Numpy installed, Matplotlib installedInstallation>>> pip install numpy >>>pip install matplotlibConvolutionConvolution is a type of operation that can be performed on an image to extract the features from it by applying a smaller container called a kernel/coordinate container like a sliding window over the image. Depending on the values in the convolutional coordinate container, we can pick up specific patterns/features from the image.Here, we will learn about the detection of horizontal and vertical endpoints in ... Read More
457 Views
In this article, we will learn about the Internal working of Set in Python. We will observe the union and intersection operation in different frames and objects.Let’s declare an empty set.>>> s=set()Now let’s declare a set with elements.>>> s1=set('tutorialspoint')Adding an element into an empty set.>>> s.add(‘p’)Now we declare another set with the name of Python.>>> s2=set('python')Now let’s see the union operation.>>> s3=s1.union(s2)Finally, we implement the intersection option.>>> s4=s1.intersection(s2)ConclusionIn this article, we learned about the Internal working of Set in Python 3.x. Or earlierRead More
2K+ Views
In this article, we will learn about the internal working of python & how different objects are allocated space in the memory by the python interpreter.Python is an object-oriented programming construct language like Java. Python uses an interpreter and hence called an interpreted language. Python supports minimalism and modularity to increase readability and minimize time and space complexity. The standard implementation of python is called “cpython” and we can use c codes to get output in python.Python converts the source code into a series of byte codes. So within python, compilation stage happens, but directly into byte code and this ... Read More
350 Views
In this tutorial, we will learn about the internal working of the list in Python 3.x. Or earlier. We will also look at the object and frame formation when we write a python statement at each step.Initializing the list: This means that we are creating a list with some elements.>>> lis=[1, 2, 3, 4]Here list variable is declared in the global frame which is referring to a list object as shown aboveNow let’s see what happened when we append the element in the list.>>> lis.append(8)Here the element is added at the end and the size of the list is increased ... Read More
166 Views
In this article, we will learn about defining and user-defined functions to predict the next greatest element.Problem statementWe are given an array & we need to print the Next Greater Element for every element present in the array. The Next greater Element for an arbitrary element y is the first greatest element present on the right side of x in array. Elements for which no greatest element exist, return -1 as output.4Input test case[12, 1, 2, 3]Output12 -> -1 1 -> 3 2 -> 3 3 -> -1Now let’s observe the source code.Example# Function Def elevalue(arr): # Iteration ... Read More
408 Views
A JTree is a component that presents a hierarchical view of data. The user has the ability to expand or collapse individual sub-trees. A TreeNode interface defines the methods that must be implemented nodes of a JTree object. The DefaulMutableTreeNode class provides a default implementation of a TreeNode interface. We can disable the leaf of JTree by overriding the getTreeCellRendererComponent() method of DefaultTreeCellRenderer class.Syntaxpublic Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus)Exampleimport java.awt.*; import javax.swing.tree.*; import javax.swing.*; public class JTreeLeafNodeDisableTest extends JFrame { private TreeNode treeNode; private JTree tree; public JTreeLeafNodeDisableTest() { setTitle("JTreeLeafNodeDisable Test"); ... Read More
288 Views
In this article, we will learn the implementation and usage of issubset() function available in the Python Standard Library.The issubset() method returns boolean True when all elements of a set are present in another set (passed as an argument) otherwise, it returns boolean False.In the figure given below B is a subset of A. In case A & B are identical sets mean that A is a proper subset of B. This means both sets contain the same elements in them.Syntax.issubset()Return valueboolean True/FalseNow let’s look at an illustration to understand the concept.Example Live DemoA = {'t', 'u', 't', 'o', 'r', 'i', ... Read More
445 Views
In this article, we will learn about Input/Output from an external files in C/C++, Java, and Python for Competitive Programming.Python I/O from the fileIn python, the sys module is used to take input from a file and write output to the file. Let’s look at the implementation in the form of code.Exampleimport sys # For getting input sys.stdin = open('sample.txt', 'r') # Printing the Output sys.stdout = open('sample.txt', 'w')Java I/O from the fileHere we take the help of buffered reader method to take input associated with file reader to read input from file and print writer to print the data ... Read More