Found 10784 Articles for Python

Python Program for GCD of more than two (or array) numbers

Pavitra
Updated on 11-Sep-2019 11:53:55

1K+ Views

In this article, we will learn about the solution to the problem statement given below −Problem statement − We will be given an array of number and we need to find the greatest common divisor.If we need to find gcd of more than two numbers, gcd is equal to the product of the prime factors common to all the numbers provided as arguments. It can also be calculated by repeatedly taking the GCDs of pairs of numbers of arguments.Here we will be implementing the latter approachSo now, let’s see the implementationExample Live Demodef findgcd(x, y):    while(y):       x, ... Read More

Python Program for the focal length of a spherical mirror

Pavitra
Updated on 11-Sep-2019 11:51:14

243 Views

In this article, we will learn about the solution to the problem statement given below −Problem statementWe will be given the radius of curvature of the spherical mirror and we have to find the focal length of the same.The focal length is the distance between the centre of curvature of the mirror to the principal foci. In order to determine the focal length of a spherical mirror firstly, we should know the radius of curvature of that mirror. The distance from the vertex of the mirror to the centre of curvature is called the radius of curvature.Mathematically −For concave mirror: ... Read More

Python Program for Finding the vertex, focus and directrix of a parabola

Pavitra
Updated on 11-Sep-2019 11:48:11

842 Views

In this article, we will learn about the solution to the problem statement given below −Problem statementThe standard form of a parabola equation is y=ax^2+bx+c. Input the values of a, b and c, our task is to find the coordinates of the vertex, focus and the equation of the directrix.The vertex of a parabola is the coordinate from which it takes the sharpest turn whereas y=a is the straight-line used to generate the curve.A directrix a fixed-line used in describing a curve or surface.Now let’s see the implementation −Example Live Demodef findparabola(a, b, c):    print ("Vertex: (" , (-b / ... Read More

Python Program for Find the perimeter of a cylinder

Pavitra
Updated on 11-Sep-2019 11:45:20

82 Views

In this article, we will learn about the solution to the problem statement given below −Problem statement − Input diameter and height, find the perimeter of a cylinderPerimeter is nothing but the side view of a cylinder i.e. a rectangleTherefore Perimeter= 2 * ( h + d )here d is the diameter of the cylinderh is the height of the cylinderNow let’s see the implementationExample Live Demo# Function to calculate the perimeter of a cylinder def perimeter( diameter, height ) :    return 2 * ( diameter + height ) # main diameter = 5 ; height = 10 ; print ... Read More

Windows 10 Toast Notifications with Python

Pavitra
Updated on 30-Aug-2019 12:55:21

766 Views

We can create a notifier for the events that occurred in Windows using Python. This is very simple with the win10toast module. If you are familiar with the Toast in Android then understanding the Toast notifications with Python is a piece of cake. We can generate notifications whenever an event occurs as a remainder. Let's see.Run the following command in command-line to install win10toast modulepip install win10toastIf the module successfully installed then, you will get the following result when you run the command.Collecting win10toast Downloading https://files.pythonhosted.org/packages/d4/ba/95c0ea87d9bcad68b90d8cb130a313b939c88d8338a2fed7c11eaee972fe/win10toast-0.9-py2.py3-none-any.whl Collecting pypiwin32 (from win10toast) Downloading https://files.pythonhosted.org/packages/d0/1b/2f292bbd742e369a100c91faa0483172cd91a1a422a6692055ac920946c5/pypiwin32-223-py3-none-any.whl Requirement already satisfied: setuptools in c:\users\hafeezulkareem\anaconda3\lib\site-packages (from win10toast) ... Read More

What are the tools to support Data Science other than Python and R?

Pavitra
Updated on 29-Aug-2019 12:21:47

85 Views

In this article, we will learn about the tools to support Data Science other than Python and R?Here we will look at five tools that help in implementing the concept of data science.Apache HadoopJava-based free softwareLarge storage capabilityThe splitting capacity of dataNosqlMore structured orientationBetter performance efficiencyOpen-source software efficiencyHiveDistributed data management systemHighly useful in data miningTorchScientific computing frameworkIt uses Lua programming languageIt can easily implement deep learning algorithmsDomino data labUnified data science toolIncreases iteration speedRemoves deployment frictionConclusionIn this article, we learned about some of the powerful tools available in the field of data science other than Python & R.

Looping Techniques in Python

Pavitra
Updated on 29-Aug-2019 12:09:14

182 Views

In this tutorial, we will learn about looping techniques in python 3.x. Or earlier. There are many ways in which we can implement loops. Here we will be discussing four techniques in looping.Enumeration constructExample Live Demo# enumerate() type for index, value in enumerate(['Tutorial', 'point']):    print(index, value)Output0 Tutorial 1 pointZip constructExample Live Demo# zip() method arr1 = ['Tutorial', 'point'] arr2 = ['python', 'loops'] for i, j in zip(arr1, arr2):    print(i, j)OutputTutorial python point loopsMembership constructExample Live Demo# membership operator for i in ['Tutorial', 'point']:    print(i)OutputTutorial pointInfinitive constructExample# infinite loop while(True):    passStep - based constructExample# range with step incrementer For i ... Read More

K’th Non-repeating Character in Python using List Comprehension and OrderedDict

Pavitra
Updated on 29-Aug-2019 12:01:21

240 Views

In this article, we will learn about K’th Non-repeating Character in Python using List Comprehension and OrderedDict. To do so we take the help of inbuilt constructs available in Python.Algorithm1. First, we form a dictionary data from the input. 2. Now we count the frequency of each character. 3. Now we extract the list of all keys whose value equals 1. 4. Finally, we return k-1 character.Examplefrom collections import OrderedDict import itertools def kthRepeating(inp, k):    # returns a dictionary data    dict=OrderedDict.fromkeys(inp, 0)       # frequency of each character    for ch in inp:       ... Read More

Iterator Functions in Python

Pavitra
Updated on 29-Aug-2019 11:56:38

272 Views

In this article, we will learn about the four iterator functions available in Python 3.x. Or earlier namely accumulate() , chain(), filter false() , dropwhile() methods.Now let’s look on each of them in detail −Accumulate () & chain() methodAccumulate() method takes two arguments, one being iterable to operate on and another the function/operation to be performed. By default, the second argument performs the addition operation.Chain() method prints all the iterable targets after concatenating all of the iterables.The below example explains the implementation −Example Live Demoimport itertools import operator as op # initializing list 1 li1 = ['t', 'u', 't', 'o', 'r'] ... Read More

Introduction-to-convolutions-using-python

Pavitra
Updated on 29-Aug-2019 11:47:42

156 Views

In this article, we will learn about convolutions in Python 3.x. Or earlier. This articles come under neural networks and feature extraction.Ide preferred − Jupyter notebookPrerequisites − Numpy installed, Matplotlib installedInstallation>>> pip install numpy >>>pip install matplotlibConvolutionConvolution is a type of operation that can be performed on an image to extract the features from it by applying a smaller container called a kernel/coordinate container like a sliding window over the image. Depending on the values in the convolutional coordinate container, we can pick up specific patterns/features from the image.Here, we will learn about the detection of horizontal and vertical endpoints in ... Read More

Advertisements