- 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 10805 Articles for Python
273 Views
In this article, we will learn about the solution and approach to solve the given problem statement.Problem statement −Given the side of a tetrahedron, we need to find a tetrahedron.A Tetrahedron is a geometric figure which looks like a pyramid with a triangular base. It is a solid object with four triangular faces, three on the sides, one on the bottom of the base and four vertices or corners.Here we frame an area function as shown below −Exampleimport math def areatetrahedron(side): return (math.sqrt(3) * (side * side)) # Driver Code side = 20 print("Area of Tetrahedron = ", area_of_tetrahedron(side))OutputArea ... Read More
133 Views
In this article, we will learn about the web scraping technique using the Scrappy module available in Python.What is web scraping?Web scraping is used to obtain/get the data from a website with the help of a crawler/scanner. Web scrapping comes handy to extract the data from a web page that doesn't offer the functionality of an API. In python, web scraping can be done by the help of various modules namely Beautiful Soup, Scrappy & lxml.Here we will discuss web scraping using the Scrappy module.For that, we first need to install Scrappy.Type in the terminal or command prompt>>> pip install ... Read More
1K+ Views
In this article, we will learn about the calculation of simple interest in Python 3.x. Or earlier.Simple interest is calculated by multiplying the daily interest rate by the principal amount by the number of days that elapse between the payments.Mathematically, Simple Interest = (P x T x R)/100 Where, P is the principal amount T is the time and R is the rateFor example, If P = 1000, R = 1, T = 2 Then SI=20.0 Now let’s see how we can implement a simple interest calculator in Python.Example Live DemoP = 1000 R = 1 T = 2 # simple ... Read More
2K+ Views
In this article, we will learn about the Selection sort and its implementation in Python 3.x. Or earlier.In the selection sort algorithm, an array is sorted by recursively finding the minimum element from the unsorted part and inserting it at the beginning. Two subarrays are formed during the execution of Selection sort on a given array.The subarray, which is already sortedThe subarray, which is unsorted.During every iteration of selection sort, the minimum element from the unsorted subarray is popped and inserted into the sorted subarray.Let’s see the visual representation of the algorithm −Now let’s see the implementation of the algorithm ... Read More
121 Views
In this article, we will learn about the solution to the problem statement given below −Problem statement − We are given a string, we have to remove the ith indexed character from the given string and display it.In any string in Python, indexing always starts from 0. Suppose we have a string “tutorialspoint” then its indexing will be done as shown below −T u t o r i a l s p o i n t 0 1 2 3 4 5 6 7 8 9 10 11 12 13Now let’s see the Python script for ... Read More
905 Views
In this article, we will learn about the solution to the problem statement given below −Problem statement − Given a number n, we need to find the product of all of its unique prime factors available and return it.For example, Input: num = 11 Output: Product is 11 Explanation: Here, the input number is 11 having only 1 prime factor and it is 11. And hence their product is 11.Approach 1Using a for loop from i = 2 to n+1 check whether i is a factor of n & then check if i is the prime number itself, if yes ... Read More
513 Views
In this article, we will learn about the solution to the problem statement given below −Problem statement − Given Two number N and K, our problem is to subtract a number K from N until number(N) is greater than zero(0), once the N becomes negative or zero then we start adding K to it until that number become the original number(N).For example, N = 10 K = 4 Output will be: 10 6 2 -2 2 6 10Algorithm1. we call the function again and again until N is greater than zero (in every function call we subtract K ... Read More
1K+ Views
In this article, we will compute the nth Fibonacci number.A Fibonacci number is defined by the recurrence relation given below −Fn = Fn-1 + Fn-2With F0= 0 and F1 = 1.First, few Fibonacci numbers are0,1,1,2,3,5,8,13,..................We can compute the Fibonacci numbers using the method of recursion and dynamic programming.Now let’s see the implementation in the form of Python scriptApproach 1: Recursion MethodExample Live Demo#recursive approach def Fibonacci(n): if n
156 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
400 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