loops

All Divisors of a Number in Python

In the previous article, we saw how we can determine a Prime Number using Python logic and syntax. In this article we will explore All Divisors of a Number in Python. Imagine that we have a tower of height 12 using equal size blocks, we need to find the size of all the blocks that …

Prime Number in Python

In the previous article we saw about Fibonacci Numbers, now we will learn how we can check if a user given number is a prime number. Let us look at a program involving prime numbers, we are given a tower of height 91 which is made using some blocks. The blocks should all be of …

Optimized solutions in Python for All Divisors and Prime Number

In the previous article we explored programs for obtaining all divisors of a given number. Let us see the ways in which we can discuss optimize the programs in the previous article as well as the program for Prime Numbers. Optimizing programs in recent usage or legacy code is important as we gain new knowledge …

Fibonacci Numbers in Python

In the previous article we explored the LCM Concept and two different ways we can obtain them, now we will look at what the Fibonacci numbers are and how they can be obtained or the way in which Fibonacci Numbers in Python are implemented. Let us look at a problem involving Fibonacci numbers: There are …

LCM of two Numbers in Python

In the previous article we explored about GCD and it’s implementation in Python. Now let us explore the concept of LCM and how we can arrive at the LCM of two Numbers in Python. Before we delve further into Python let us look at a problem which can further/or revise our understanding of LCM. We …

GCD of two numbers in Python

In the previous article, we explored two different approaches towards obtaining the factorial of a number. In this current article we will explore how we can obtain the GCD of two numbers in Python. The common divisor of several integers is a number that can be a divisor of each number in the specified set. For example, …

Factorial Program in Python

In the previous article we have seen the logic and code for obtaining the count of the digits in a number, in this article we will see how we can obtain the Factorial of any user-entered number in Python. Before we discuss the Factorial Program in Python, let us revise the concept of Factorial. The …

While Loops in Python

In the previous lesson we have seen why loops are essential in programming languages, in this article we will explore a common type of loop present, that is the While loops in Python. While loop is a loop which first checks whether a particular condition matches, and then executes the statements which are embedded within …

Loops in Python

In the previous article we have seen the Calculator implementation , now we will go through the concept of loops in Python. Looping structures are instrumental in reducing the repeated statements or complexity of code. Let us look at the example of multiplication tables. We need to write a program that accepts a user input …

Python program to count the Digits

In the previous article we wrote a program to print Pyramid patterns in Python, now let us look at a program to count the number of digits present in a program. The program should be written in such a way as to accept numeric input values from the user which are greater than 0, the …