Found 10805 Articles for Python

How to use contains() in android LinkedBlockingDeque?

Samual Sam
Updated on 30-Jun-2020 14:13:06

63 Views

Before getting into example, we should know what LinkedBlockingDeque is. It is implemented by Collection interface and the AbstractQueue class. It provides optional boundaries based on linked nodes.It going to pass memory size to constructor and helps to provide memory wastage in android.This example demonstrate about How to use contains() in android LinkedBlockingDequeStep 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.     In the above code, we have taken text view to show ... Read More

Linear Regression using Python?

Jennifer Nicholas
Updated on 30-Jul-2019 22:30:25

537 Views

Linear regression is one of the simplest standard tool in machine learning to indicate if there is a positive or negative relationship between two variables.Linear regression is one of the few good tools for quick predictive analysis. In this section we are going to use python pandas package to load data and then estimate, interpret and visualize linear regression models.Before we go down further down, let’s discuss what is regression first?What is Regression?Regression is a form of predictive modelling technique which helps in creating a relationship between a dependent and independent variable.Types of RegressionLinear RegressionLogistic RegressionPolynomial RegressionStepwise RegressionWhere is Linear ... Read More

Difference between various Implementations of Python?

AmitDiwan
Updated on 12-Aug-2022 12:08:24

149 Views

Most developers know about python, irrespective of what python is implemented in their system. Therefore, what do I mean by “python”, is it a python the abstract interface? Do we mean CPython, the common Python implementation (not the Cython)?. Or we mean something else entirely? Or we mean Jython or IronPython or PyPy. While the technologies mentioned above are commonly-named and commonly-referenced, however some of them serve completely different purposes. We can think of python as a specification for a language that can be implemented in many different ways. In this tutorial we’ll go through the following implementation of python ... Read More

Working with PDF files in Python?

Vrundesha Joshi
Updated on 30-Jul-2019 22:30:25

1K+ Views

Python is a very versatile language as it provides huge set of libraries to work on different requirements. We all work on Portable Document Format (PDF) files. Python provides different ways to work with pdf files. In this we are going to use python library called PyPDF2 to work with pdf file.PyPDF2 is a pure-python PDF library capable of splitting, merging together, cropping, and transforming the pages of PDF files. It can also add custom data, viewing options, and passwords to PDF files. It can retrieve text and metadata from PDFs as well as merge entire files together.As we can ... Read More

Junk File Organizer in Python?

Jennifer Nicholas
Updated on 30-Jul-2019 22:30:25

397 Views

This might seem very useful for a lazy python programmer who keeps most of the files and folders at one location and sometimes at confused what all files are there and surely he is too lazy to do it manually. So below is a python program to organize or simplify everything in appropriate folder in the single go and remove empty directories.So we have a directory path where lots of files of different types are present (like below) and our program we segregate each file type into their respective folders (like below).Input folder structureDesired OutputFirst create different folders based on ... Read More

Determine the type of an image in Python?

Nitya Raut
Updated on 30-Jul-2019 22:30:25

3K+ Views

In this section we are going to see the type of image file we have. So consider a situation, where in a directory we have hundreds of image file and we want to get all the jgeg(or any particular image file type) file type. All this we are going to do programmatically using python.Python provide library to determine the type of an image, on such library is imghdr.The python imghdr package determines the type of image contained in a file or byte stream.InstallationThere is a very much chances that if you are using python 3.6 or higher, imghdr module is ... Read More

Command Line Interface Programming in Python?

Jennifer Nicholas
Updated on 30-Jul-2019 22:30:25

542 Views

In this section we are going to develop a command line interface using python. But before we deep dive into program, lets first understand command line.Command line are in use since the existence of computer programs and are built on commands. A command line program is a program that runs from a shell or from a command lineWhile command line interface provides user interface that is navigated by typing commands at terminals, shells or consoles instead of using the mouse.A command-line interface(CLI) starts with an executable. There are parameters which we can pass to the script depending how they are ... Read More

Understanding Logistic Regression in Python?

Nitya Raut
Updated on 30-Jul-2019 22:30:25

245 Views

Logistic Regression is a statistical technique to predict the binary outcome. It’s not a new thing as it is currently being applied in areas ranging from finance to medicine to criminology and other social sciences.In this section we are going to develop logistic regression using python, though you can implement same using other languages like R.InstallationWe’re going to use below libraries in our example program, Numpy: To define the numerical array and matrixPandas: To handle and operate on dataStatsmodels: To handle parameter estimation & statistical testingPylab: To generate plotsYou can install above libraries using pip by running below command in ... Read More

Hangman Game in Python?

Jennifer Nicholas
Updated on 30-Jul-2019 22:30:25

485 Views

Hangman is a classic word game in which participants needs to guess as many secret words as you can before time runs out! So, it’s a nice game to learn new words, one letter at a time!So we are going to write python script for this classic game “hangman”.#importing the time module import time #welcoming the user name = input("What is your name? ") print("Hello, " + name, "Time to play hangman!") print ("") #wait for 1 second time.sleep(1) print ("Start guessing...") time.sleep(0.5) #here we set the secret word= ("Secret") word = word.lower() ... Read More

Python Rational numbers (fractions)

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

2K+ Views

Any number which can be expressed as a quotient or fraction in the form of p/q is called a rational number. The fractions module of Python library provides functionality for rational number arithmetic.This module defines a Fraction class. Its object can be constituted in various ways as below −Fraction(num, denom)The first version of Fraction constructor receives two parameters for numerator and denominator. Default numerator is 0 and default denominator is 1. Value of denominator = 0 throws ZeroDivisionError.>>> from fractions import Fraction >>> n1 = Fraction(2, 5) >>> n1 Fraction(2, 5) >>> n2 = Fraction(6, 15) >>> n2 Fraction(2, 5) ... Read More

Advertisements