
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
Found 10476 Articles for Python

4K+ 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

883 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

391 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

620 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

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

577 Views
The statistics module of Python library consists of functions to calculate statistical formulae using numeric data types including Fraction and Decimal types.Following import statement is needed to use functions described in this article.>>> from statistics import *Following functions calculate the central tendency of sample data.mean() − This function calculates the arithmetic mean of data in the form of sequence or iterator.>>> from statistics import mean >>> numbers = [12, 34, 21, 7, 56] >>> mean(numbers) 26The sample data may contain Decimal object or Fraction object>>> from decimal import Decimal >>> numbers = [12, 34, 21, Decimal('7'), 56] >>> mean(numbers) Decimal('26') ... Read More

271 Views
To get the geographic coordinates of the place that is longitude and latitude of the place we can use google maps geocoding api.RequirementTo get the coordinates of a place, we required geocoding api & you can get it from below link:https://developers.google.com/maps/documentation/geocoding/get-api-keyApart from api_key, we are going to use pythonRequest module (fetch the coordinates)Json module (for conversion).Below is the program to achieve the same:# Import required library import requests import json #Enter the place name place = input("Please enter place name: ") #Place your google map API_KEY to a variable apiKey = 'YOUR_API_KEY' #Store google geocoding api url in a variable ... Read More

806 Views
We almost all use google maps to check distance between source and destination and check the travel time. For developers and enthusiasts, google provide ‘google distance matrix API’ to calculate the distance and duration between two places.To use google distance matrix api, we need google maps API keys, which you can get from below link:https://developers.google.com/maps/documentation/distance-matrix/get-api-keyRequired librariesWe can accomplish this by using different python library, like:PandasgooglemapsRequestsJsonI am using very basic requests and json library. Using pandas you can fill multiple source and destination places at a time and get the result in csv file.Below is the program to implement the same:# ... Read More

956 Views
We generally open the browser to search for a specific site/place on google maps. And if you need to do this task multiple times a day, it becomes very boring. Now you can automate this task where your browser will open automatically and the webpage will show you the google maps of your desired location.InstallationFor this purpose, I’m going to use the paperclip package. As this is not the standard package, we need to install it using pip.>pip install pyperclip Collecting pyperclip Downloading https://files.pythonhosted.org/packages/2d/0f/4eda562dffd085945d57c2d9a5da745cfb5228c02bc90f2c74bbac746243/pyperclip-1.7.0.tar.gz Building wheels for collected packages: pyperclip Building wheel for pyperclip (setup.py) ... done Stored in directory: ... Read More

497 Views
Python pygmaps library provides a wrapper for the google maps javascript api. With this library python users can create a matplotlib like interface to generate the html and javascript and then can depicts all the additional information user’s would like to add on top of Google Maps.Required libraryWe are only going to use the pygmaps library/package. You can install the pygmaps library using pip, like:$pip install pygmaps (windows os) $sudo pip3 install pygmaps (linux os)We are going to write a program which will display -Create a map using pygmaps by providing long, lat & zoom level.Set grids on map by ... Read More