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
Python Articles - Page 907 of 1048
164 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
284 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
441 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
397 Views
In this article, we will learn about different IDE’s available on Python for windows.PycharmInteractive python consoleSupport for web frameworksFaster refracting timeLesser developmentJupyter notebookCompatibility with almost every python moduleLesser space and hardware requirementsInbuilt terminal and kernel featuresA wide variety of widgets can be appliedWing ideInbuilt debugging toolsSupport for unit testingEasy code navigation capability.Komodo ideThird-party library supportXML autocompletionInbuilt refracting capacity.Sublime textCross-platformMultitaskingBetter customizationAtomBetter customizationBetter user interfaceCross-platform editorConclusionIn this article, we learned about IDE for Python programming on windows.
145 Views
In this article, we will learn about issuperset() in Python and its implementation in various areas.This method returns boolean True if all elements of a set B contains all elements set A which is passed as an argument and returns false if all elements of A not present in B.This means if B is a superset of A then itreturns true; else FalseExampleLet’s look at some example Live DemoA = {'t', 'u', 't', 'o', 'r', 'i', 'a', 'l'} B = {'t', 'u', 't'} print("A issuperset B : ", A.issuperset(B)) print("B issuperset A : ", B.issuperset(A))OutputA issuperset B : True B issuperset ... Read More
213 Views
In this article, we will learn about some Interesting facts about strings in Python 3.x. Or earlier.ImmutabilityAuto-detection of escape sequencesDirect slicingIndexed accessImmutabilityThis means that there is no permission of modification on type and we only have read only access to the strings.Exampleinp = 'Tutorials point' # output print(inp) # assigning a new value to a particular index in a string inp[0] = 't' print(inp) # raises an errorOutputTypeError: 'str' object does not support item assignmentAuto-detection of escape sequencesThe strings containing backslash are automatically detected as an escape sequence.Exampleinp = 'Tutorials point' # output print(inp+””+”101”)OutputTutorials point 101Direct slicingWe all are aware ... Read More
178 Views
In this article, we will about the implement isNumber() method using Python 3.x. Or earlier.This method takes in a string type as input and returns boolean True or False according to whether the entered string is a number or not. To do this we take the help of exception handling by using try and except statement.ExampleLet’s look at some example − Live Demo# Implementation of isNumber() function def isNumber(s): if(s[0] =='-'): s=s[1:] #exception handling try: n = int(s) return True # catch exception if any error is encountered ... Read More
260 Views
In this article, we will learn about what all features makes python cool and different from other languages.>>>import thisOutputThe Zen of Python, by Tim Peters Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. The flat is better than nested. Sparse is better than dense. Readability counts. Special cases aren't special enough to break the rules. Although practicality beats purity. Errors should never pass silently. Unless explicitly silenced. In the face of ambiguity, refuse the temptation to guess. There should be one-- and preferably only one --obvious way to ... Read More
573 Views
In this article, we will learn about how the input function behaves in an undesirable manner in version 2.x. Or earlier. In version 2.x. the raw_input() function works as replacement of the input() function . In newer versions 3.x. or later all the desirable features & functionalities of both functions are merged into the input() function.Firstly let’s look at the input type of built-in functions for taking input in Python 2.x.Example# Input Given : String str1 = raw_input("Output of raw_input() function: ") print type(str1) str2 = input("Output of input() function: ") print type(str2) # Input Given : Float str3 = ... Read More
210 Views
In this article, we will learn about how we can make a string into a pangram using the counter() function in Python 3.x. Or earlier. To do so we are allowed to remove any character from the input string. We will also find the number of such required characters to be removed to make the string into an anagram.Two strings are said to be anagrams of each other when they contain the same type of alphabets in any random order.The counter () method is present in the collection module available in Python. The prerequisite is to import the collections module ... Read More