Category: Python Programs

python tutorials and learn python

Created with Sketch.

Python program to print all happy numbers between 1 and 100

Python Program to Print Happy Numbers Between 1 and 100 Introduction In this blog post, we will explore and implement a Python program to print all Happy Numbers within the range of 1 to 100. Happy Numbers are a fascinating mathematical concept that involves a sequence of operations on the digits of a number. We…
Read more

Python program to check if the given number is Happy Number

Python program to check if the given number is Happy Number A number is said to be happy if it yields 1 when replaced by the sum of squares of its digits repeatedly. If this process results in an endless cycle of numbers containing 4, then the number will be an unhappy number. Let’s understand…
Read more

Python program to print all disarium numbers between 1 and 100

Introduction In this blog post, we will explore a Python program that identifies and prints all Disarium numbers within the range of 1 to 100. Disarium numbers are those whose sum of each digit, each raised to the power of its respective position, equals the number itself. Python Program   Program Explanation The program defines…
Read more

Python program to check if the given number is a Disarium Number

Python program to check if the given number is a Disarium Number A number is said to be the Disarium number when the sum of its digit raised to the power of their respective positions becomes equal to the number itself. For example, 175 is a Disarium number as follows: 11+ 72 + 53 =…
Read more

 Python program to sort the elements of an array in descending order

 Python program to sort the elements of an array in descending order In this program, we need to sort the given array in descending order such that elements will be arranged from largest to smallest. This can be achieved through two loops. The outer loop will select an element, and inner loop allows us to…
Read more

 Python program to sort the elements of an array in ascending order

 Python program to sort the elements of an array in ascending order In this program, we need to sort the given array in ascending order such that elements will be arranged from smallest to largest. This can be achieved through two loops. The outer loop will select an element, and inner loop allows us to…
Read more

 Python program to right rotate the elements of an array

 Python program to right rotate the elements of an array In this program, we need to rotate the elements of array towards its right by the specified number of times. An array is said to be right rotated if all elements of the array are moved to its right by one position. One approach is…
Read more

Python program to print the sum of all elements in an array

Python program to print the sum of all elements in an array In this program, we need to calculate the sum of all the elements of an array. This can be solved by looping through the array and add the value of the element in each iteration to variable sum.   Sum of all elements…
Read more

Python program to print the number of elements present in an array

Python program to print the number of elements present in an array In this program, we need to count and print the number of elements present in the array. Some elements present in the array can be found by calculating the length of the array.   Length of above array is 5. Hence, the number…
Read more

Python program to print the smallest element in an array

Python program to print the smallest element in an array In this program, we need to find out the smallest element present in the array. This can be achieved by maintaining a variable min which initially will hold the value of the first element. Loop through the array by comparing the value of min with…
Read more