Category: Python Programming Examples

python tutorials and learn python

Created with Sketch.

Python Program for Difference between sums of odd and even digits

Python Program for the Difference between Sums of Odd and Even Digits Introduction In this blog post, we will explore a Python program that calculates the difference between the sums of odd and even digits in a given integer. The program extracts individual digits from the number, categorizes them as odd or even, and computes…
Read more

Python Program for Find minimum sum of factors of number

Python Program: Find Minimum Sum of Factors of a Number Introduction In this blog post, we’ll explore a Python program that calculates the minimum sum of factors for a given number. The program will take a number as input, find its factors, and determine the minimum sum of those factors. We’ll discuss the algorithm, provide…
Read more

Python Program for Check if count of divisors is even or odd

Python Program: Check if Count of Divisors is Even or Odd In this blog post, we’ll explore a Python program that checks whether the count of divisors for a given number is even or odd. We’ll discuss the algorithm, provide a step-by-step explanation, present the Python code, and include examples with outputs. Understanding the Algorithm…
Read more

Python Program for GCD of more than two (or array) numbers

Python Program for GCD of more than two (or array) numbers The GCD of three or more numbers equals the product of the prime factors common to all the numbers, but it can also be calculated by repeatedly taking the GCDs of pairs of numbers. gcd(a, b, c) = gcd(a, gcd(b, c)) = gcd(gcd(a, b),…
Read more

Python Program for Maximum height when coins are arranged in a triangle

Python Program for Maximum height when coins are arranged in a triangle We have N coins which need to arrange in form of a triangle, i.e. first row will have 1 coin, second row will have 2 coins and so on, we need to tell maximum height which we can achieve by using these N…
Read more

Python Program for Common Divisors of Two Numbers

Python Program for Common Divisors of Two Numbers Given two integer numbers, the task is to find count of all common divisors of given numbers? Input : a = 12, b = 24 Output: 6 // all common divisors are 1, 2, 3, // 4, 6 and 12 Input : a = 3, b =…
Read more

Python Program for Number of elements with odd factors in given range

Python Program for Number of Elements with Odd Factors in a Given Range In this blog post, we will explore a Python program that counts the number of elements within a given range that have an odd number of factors. We’ll discuss the algorithm used and provide a complete Python code example with detailed explanations.…
Read more

Python Program for Extended Euclidean algorithms

Python Program for Extended Euclidean algorithms # Python program to demonstrate working of extended # Euclidean Algorithm   # function for extended Euclidean Algorithm def gcdExtended(a, b, x, y):     # Base Case     if a == 0 :          x = 0         y = 1         return b               x1 = 1     y1 = 1 # To store…
Read more

Python Program for Basic Euclidean algorithms

Python Program for Basic Euclidean algorithms # Python program to demonstrate Basic Euclidean Algorithm     # Function to return gcd of a and b def gcd(a, b):      if a == 0 :         return b            return gcd(b%a, a)   a = 10 b = 15 print(“gcd(“, a , “,” , b, “) = “,…
Read more

Python | Check if binary representation is palindrome

Python | Check if Binary Representation is Palindrome Introduction In this blog post, we will explore how to write a Python program to check if the binary representation of a number is a palindrome. Palindromes are sequences that read the same backward as forward. For binary numbers, checking if the binary representation is a palindrome…
Read more