
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

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

266 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

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

723 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

527 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

578 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

418 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