Found 10807 Articles for Python

Conway’s Game Of Life using Python?

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

437 Views

A British mathematician in an around 1970 created his “Game of Life” – which are basically a set of rules depicting the chaotic yet patterned growth of a colony of biological organisms. The “Game of Life” is a two-dimensional grid consists of “living” and “dead” cells.Rules of Game of lifeOverpopulation: A cell dies(off) if its surrounded by more than three living cells.Static: A cell lives(on) if its surrounded by two or three living cells.Underpopulation: A cell dies(off) if its surrounded by fewer than two living cells.Reproduction: A cell becomes live(on) if a dead cell is surrounded by exactly three cells. Cell ... Read More

Run Python script from Node.js using child process spawn() method?

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

1K+ Views

NodeJs and Python are two main preferred languages among developers and web designers. But there are couple of areas where NodeJs fall short of python are numerical and scientic computation (AI, Machine learning, deep learning etc.). Whereas python provides lots of libraries to work with scientific computing lot easier.Luckly, we can utilise the python libraries within our nodejs application by running python in the background and return back the result.For this we are going to use the child_process standard library of NodeJs to spawn a pyton process in the background, do computation and return back the result to our node ... Read More

Identifying handwritten digits using Logistic Regression in PyTorch?

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

183 Views

In this we are going to use PyTorch to train a CNN to recognize handwritten digit classifier using the MNIST dataset.MNIST is a widely used dataset for hand-written classification task covering more than 70k labeled 28*28 pixel grayscale images of handwritten digits. The dataset contains almost 60k training images and 10k test images. Our job is to train a model using 60k training images and subsequently test its classification accuracy on 10k test images.InstallationFirst we need the MXNet latest version, for that just run the following on your terminal:$pip install mxnetAnd you will something like, Collecting mxnet Downloading https://files.pythonhosted.org/packages/60/6f/071f9ef51467f9f6cd35d1ad87156a29314033bbf78ad862a338b9eaf2e6/mxnet-1.2.0-py2.py3-none-win32.whl (12.8MB) ... Read More

Python module Newspaper for Article scraping & curation?

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

346 Views

We can extract content in web pages from a variety of domains such as data mining, information retrieval etc. To extract information from the websites of newspapers and magazines we are going to use newspaper library.The main purpose of this library is to extract and curates the articles from the newspapers and similar websites.Installation:To Newspaper library installation, run in your terminal:$ pip install newspaper3kFor lxml dependencies, run below command in your terminal$pip install lxmlTo install PIL, run$pip install PillowThe NLP corpora will be downloaded:$ curl https://raw.githubusercontent.com/codelucas/newspaper/master/download_corpora.py | pythonThe python newpaper library is used to collect information associated with articles. This ... Read More

Wrapping C/C++ for Python using SWIG

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

1K+ Views

There are multiple ways to wrap your existing C or C++ functionality in Python. In this section, we are going to see how we can wrap C/C++ functionality with SWIG. Below are other options to wrap c/c++ functionality in python.Manual wrappingUsing pyrex to wrap C code.CtypesSIPBoost PythonSWIG (Simple Wrapper Interface Generator) is capable of wrapping C code with numerous other languages including Perl, Python, PHP, Ruby, Tcl, C#, Common Lisp (CLISP, Allegro, CL, UFFI, CFFI), Java, Modula-3 and OCAML. Swig also supports multiple interpreted and compiled Scheme implementations (like Guile, MzScheme, Chicken) are supported.But we will discuss its implementation with ... Read More

Part of Speech Tagging with Stop words using NLTK in python?

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

164 Views

The main idea behind Natural Language Processing is machine can do some form of analysis or processing without human intervention at least to some level like understanding some part of what the text means or trying to say.While trying to process the text, computers needs to filter out useless or less-important data(words) from the text. In NLTK, useless words(data) are referred to as stop words.Installing Required libraryFirst you need the nltk library, just run the below command in your terminal:$pip install nltkSo we are going to remove these stop words, so they don’t take space in our database or taking ... Read More

Print with your own font using Python?

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

258 Views

In this, we are going to see how differently we can display our text in a very unique way using python.So let suppose I want to display “Hello, Python” and out many ways I could display my text/string (“Hello, Python”) like:Input“Hello, Python”Output 1___ ___ .__ .__ / | \ ____ | | | | ____ / ~ \_/ __ \| | | | / _ \ \ Y /\ ___/| |_| |_( ) \___|_ / \___ >____/____/\____/ /\ \/ \/ )/ __________ __ .__ \______ \___.__._/ |_| |__ ____ ____ | ___< | |\ __\ | \ / _ ... Read More

Formatted string literals (f-strings) in Python?

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

510 Views

Python now provides new way to format strings, called f-strings. This features is available from Python 3.6 under PEP-498. They are so called (f-string) because of the letter ‘f’ prefix with a string. The letter ‘f’ also indicates that these f-strings can be used for formatting.Below are some of the examples to demonstrates the use of f-strings.Program#1name = 'Rajesh' age = 13 * 3 fString = f'My name is {name} and my age is {age}' print(fString) #We can use Uppercase 'F' instead of lowercase 'f'. print(F'My name is {name} and my age is {age}') #As the fString valuation is done, ... Read More

Image based Steganography using Python?

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

539 Views

Steganography is a technique of hiding information behind the scene. It’s is not like cryptography which focuses on encrypting data(through different algorithms like SHA1, MD5 etc), steganography focuses more on hiding the data (data can be a file, image, message or video) within another file, image, message or video to avoid any attraction.So in this we’ll try to create a simple python program that hides the information behind the image without noticiable changes in the looks of the image. There are two main parts of the program – first is a decoding function that can extract secret information from an ... Read More

Image processing in Python?

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

10K+ Views

Python provides lots of libraries for image processing, including −OpenCV − Image processing library mainly focused on real-time computer vision with application in wide-range of areas like 2D and 3D feature toolkits, facial & gesture recognition, Human-computer interaction, Mobile robotics, Object identification and others.Numpy and Scipy libraries − For image manipuation and processing.Sckikit − Provides lots of alogrithms for image processing.Python Imaging Library (PIL) − To perform basic operations on images like create thumnails, resize, rotation, convert between different file formats etc.In this section we are going to see some basics of image processing in python.Install required library Our first step ... Read More

Advertisements