Found 10476 Articles for Python

Using Counter() in Python 3.x. to find minimum character removal to make two strings anagram

Pavitra
Updated on 29-Aug-2019 07:45:40

199 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

Use of min() and max() in Python

Pavitra
Updated on 29-Aug-2019 07:19:11

453 Views

In this article, we will be learning about min and max functions included in the Python Standard Library. It accepts infinite no of parameters according to the usageSyntaxmax( arg1, arg2, arg3, ...........)Return Value − Maximum of all the argumentsErrors & Exceptions: Here error is raised only in the scenario where the arguments are not of the same type. Error is encountered while comparing them.Let’s see what all ways we can implement the max() function first.Example Live Demo# Getting maximum element from a set of arguments passed print("Maximum value among the arguments passed is:"+str(max(2, 3, 4, 5, 7, 2, 1, 6))) # ... Read More

Union() function in Python

Pavitra
Updated on 29-Aug-2019 06:57:55

426 Views

In this article, we will be learning about union() i.e. one of the operations performed on the set() type. Union of all input sets is the smallest set which contains the elements from all sets excluding the duplicate elements present in sets.Syntax.union(, .......)Return type − typeSymbol − It is denoted by the first letter of function i.e. ‘U’ in probabilityExample Live Demo# Python 3.x. set union() function set_1 = {'a', 'b'} set_2 = {'b', 'c', 'd'} set_3 = {'b', 'c', 'd', 'e', 'f', 'g'}    # union operation on two sets print("set_1 U set_2 : ", set_1.union(set_2)) print("set_3 U set_2 ... Read More

Understanding Code Reuse and Modularity in Python 3

Pavitra
Updated on 29-Aug-2019 06:51:29

769 Views

Introduction to Object-Oriented Programming(OOP)?OOP refers to Object-Oriented Paradigm and is referred to as the heart of programming methodology. It includes several concepts like polymorphism, encapsulation, data hiding, data abstraction, inheritance & modularity.OOP gives data the prime consideration and by providing an interface through the functions associated with it. An object is a self-sufficient entity i.e. it has all the variables and associated functions with it. Objects have characteristics(variables) and features(methods), known as attributes.What is Modularity?Modularity refers to the act of partitioning the code into modules building them first followed by linking and finally combining them to form a complete project. ... Read More

Processing time with Pandas DataFrame

Pavitra
Updated on 29-Aug-2019 06:44:37

199 Views

In this article, we will learn about generating & processing different timestamps using built-in pandas library. We are also using the numpy module to generate and modify the database needed for the timestamp generation.Preferable IDE: Jupyter notebookBefore beginning this tutorial we must install pandas and numpy library. For this jupyter notebook is the best place to test and run your code. For installing pandas we must run the following command.>>> pip install pandasIf we run this command all the dependencies are automatically installed. After it’s done we must restart the kernel to see the changes.After we finished installing all the ... Read More

First-Class Citizens in Python

Pavitra
Updated on 29-Aug-2019 06:37:15

3K+ Views

First-class citizens are entities that enable support for all the operations facilitating other fellow entities.These entities are often used : while passing an argument , returning a value from function , conditional modifications & value assignment.In this article, we will look at the implementation & usage of first-class citizens in Python 3.x or earlier. Also, we will be learning what all entities get the tag of being First Class citizens.These citizens include Variables along with functions.Let’s first get familiar with the data types that are part of First-class citizensIntegersFloating typeComplex NumbersStringsAll four types mentioned above are given the tag of ... Read More

Learning Model Building in Scikit-learn: A Python Machine Learning Library

Pavitra
Updated on 29-Aug-2019 06:20:30

282 Views

In this article, we will learn about the Learning Model Building in Scikit-learn: A Python Machine Learning Library.It is a free machine learning library. It supports various algorithm like the random forest, vector machines & k-nearest neighbours with direct implementation with numpy and scipy.Importing the datasetimport pandas Url = < specify your URL here> data=pandas.rad_csv(url)Data exploration and cleaningWe can use the head method to specify/filter the records according to our needs.data.head() data.head(n=4) # restricting the record to be 4We can also implement the last few records of the datasetdata.tail() data.tail(n=4) # restricting the record to be 4Now comes the stage ... Read More

Keyboard module in Python

Pavitra
Updated on 28-Aug-2019 14:06:59

2K+ Views

In this article, we will learn about the use of the Keyboard module in Python 3.x. Or earlier.Ide preferred − Jupyter notebookInstallation −>>> pip install keyboardFunctionalities of the module −Allows us to block the action of specific keysWe can manage intents from the keyboard using on click listeners.Cross-platform compatibility.Supports special & hotkeys available on the keyboard.Now let’s implement this in the form of code −Exampleimport keyboard # It writes the content keyboard.write("Tutorialspoint") # It writes end of line keyboard.press_and_release('shift + o, shift + y, ') keyboard.press_and_release('k, j') # it blocks until ctrl keyboard.wait('Ctrl')OutputTutorialspoint O Y k jExampleimport keyboard # It ... Read More

Is the future with snake(Python) or Coffee(Java)?

Pavitra
Updated on 28-Aug-2019 14:04:53

176 Views

In this article, we will learn about the scope of python and java in implementing the upcoming and trending technologies with ease.JavaFeatures of javaIt is object-orientedIt’s is platform-independentInvolves distributed computing and network capabilitiesMultithreading is supportedSecurity is prioritizedThe stack allocation system is availableSupported/ Available frameworksSpring framework( web applications)Grails ( dynamic environment)Java server facesGoogle web toolkitPlay frameworkStruts frameworkPythonFeatures of pythonInterpreted Object-Oriented languageModular, Dynamic and robust in naturePortableCross-platform compatibilityExtensible in C/C++Extensive library and third part dependencies supportSupported/ Available frameworksDjango framework( web-based application)Flask ( webserver)Tornado ( Web sockets )Sanic framework ( multi-level handling)Giotto framework( full stack development)Bottle framework ( Rest API’s)ConclusionIn this article, we ... Read More

Introduction to Kivy; A Cross-platform Python Framework

Pavitra
Updated on 28-Aug-2019 13:56:32

827 Views

In this article, we will learn about Kivy framework and its installation. Kivy is a GUI based application interface, open-source that helps in cross-platform applications for Windows, Linux and Mac.Installation GuideFirstly we need to install python on pc.After that we need to install the dependencies −Windows −>>> python -m pip install docutils pygments pypiwin32kivy.deps.sdl2 kivy.deps.glew >>> python -m pip install kivy.deps.gstreamer >>> python -m pip install kivy.deps.angleLinux −$ sudo add-apt-repository ppa:kivy-team/kivyInstalling the Kivy fileWindows −>>> python -m pip install kivyLinux −>>> sudo apt-get install python3-kivyNow let’s see how we can make a graphical user interface using Kivy −Exampleimport kivy kivy.require('1.10.0') ... Read More

Advertisements