- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- 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 10807 Articles for Python
143 Views
In this article, we will learn about calculating the nth Catalan number.Catalan numbers are a sequence of natural numbers that are defined by the recursive formula −$$C_{0}= 1\:and\:C_{n+1}=\displaystyle\sum\limits_{i=0}^n C_{i}C_{n-i} for \:n\geq0;$$The first few Catalan numbers for n = 0, 1, 2, 3, … are 1, 1, 2, 5, 14, 42, 132,429,...................Catalan numbers can be obtained both by recursion and dynamic programming. So let’s see their implementation.Approach 1: Recursion MethodExample Live Demo# A recursive solution def catalan(n): #negative value if n
389 Views
In this article, we will learn about the solution to the problem statement given below −Problem statementGiven a number n, check whether n is a Fibonacci number or notWe all are aware that the nth Fibonacci number is the sum of the previous two Fibonacci numbers. But they also offer an interesting relation other than the recurrence relation.A number is Fibonacci in nature if and only if (5*n2 + 4) or (5*n2 – 4) is a perfect square.We will use this property to check whether a number is Fibonacci or not.Now let’s see the implementation of the Python script −Example Live ... Read More
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
209 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
739 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
72 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
698 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
67 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.
155 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
212 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