# Python

## Python program to calculate the reverse of an integer number without using strings

In this post, I’ll show a Python program to calculate the reverse of an integer number without using strings. One reason for not using strings is that we want to focus on the algorithm instead of getting a solution we don’t fully understand. The other one is that converting big numbers to strings is a […]

## Python program to calculate the greatest common divisor using the Euclidean Algorithm

The Euclidean Algorithm to calculate the greatest common divisor (GCD) has many applications. We use it in programming class for two reasons: to practice loops and recursion, and to promote algorithmic thinking. In this post, I’ll give you a description of the algorithm, as well as a few different implementations for you to practice loops

## Python program to find the prime factors of an integer number

There are many examples of problems that can help you practice with loops. One of them is to find the prime factors of an integer number. In this post, I’ll show you a python program that will calculate the prime factors of an integer. What are the prime factors of an integer number? The prime

## Python program to print the factors of a number

Creating a python program to print the factors of a number is another good exercise to keep practicing loops in any programming language. If you divide a number by a second number and you get as remainder 0, then the second number is a factor of the first one. For instance, 2 is a factor

## Palindrome in Python

Let’s examine how to determine whether a word or sentence is palindrome or not in python. Words and/or sentences are palindrome when you can read them from beginning to end and vice versa and have the same meaning. In the case of sentences, we don’t consider the spaces and punctuation. Some examples are: Civic Radar

## Python program to calculate Fibonacci numbers

Learn the best way to calculate Fibonacci numbers with this python program, as well as the recursive implementation. There is an interesting application of Fibonacci numbers. Consider that there is an idealized rabbit population. Newborn rabbits start mating in one month. And at the end of the second month, they produce another pair of rabbits.

## Python program to calculate the factorial of a number

A great example to practice both, loops and recursion, is to create a python program to calculate the factorial of a number. The factorial of a number is defined as follows: f(n) = n * f(n-1) f(0)=f(1)=1 So, let’s start with the loop version of the program. Python program to calculate the factorial of a

## Python program to add two matrices

Another example of practicing nested loops is a python program to add two matrices. Here, I’ll show the code and explain how to implement such a program. A general approach to adding two matrices When you add two matrices, you must add the numbers in the same position of each matrix, and that gives you

## Python program for arithmetic operations

Let’s create a Python program for arithmetic operations. Also known as a simple calculator in python. In this case, we are going to implement only the four basic arithmetic operations: sum, subtraction, multiplication, and division. At the end of the post, I’ll give some hints on how to add more operations. The menu for arithmetic

## Python program for Armstrong numbers

As part of the series to practice python loops, I’ll show you to create a Python program for Armstrong numbers. Armstrong numbers are those integers numbers that are equal to the sum of each digit to the power of the number of digits in the number. See the following example. 371 = 33 + 73