Category Archives: Python Programs Using Looping Statements

Find GCD By Euclidean Algorithm Python Program

Find GCD By Euclidean Algorithm – Write a Python program to find the greatest common divisor (GCD) of two numbers using the Euclidean algorithm. The Euclidean algorithm The Euclidean algorithm is a method for finding the greatest common divisor (GCD) of two integers. The algorithm is based on the principle that the GCD of two… Read More »

Loading

Python Sentence Vowel Counter Program

Python Sentence Vowel Counter  – Write a program that takes a sentence as input and counts the number of vowels (a, e, i, o, u) in it. Here’s a Python program that takes a sentence as input and counts the number of vowels (a, e, i, o, u) in it: Source Code # Function to… Read More »

Loading

Input Validation in Python

Input Validation in Python – Python Program to show number input validation. Write a program that takes a number as input and handles any exceptions that may occur if the user enters a non-numeric value. Source Code while True: try: user_input = input(“Enter a number: “) number = float(user_input) # If the input is successfully… Read More »

Loading

Python Program Execution Time Calculator

Python Program Execution Time Calculator – You can calculate the execution time of a Python program using the time module. Here’s a simple Python program that demonstrates how to measure the execution time of a block of code: import time # Record the start time start_time = time.time() # Your code to be measured goes… Read More »

Loading

Python Different Counts in String

Python Different Counts in String – Python program to count uppercase letters, lower case letters, vowels, consonants and spaces in the given string.   #Python program to count upper case letters, lower case letters #vowels, consonants and spaces in a string uppercase=0 lowercase=0 vowels=0 consonants=0 spaces=0 string=input(“Enter a String: “) for ch in string: if… Read More »

Loading

Python Program Prime Between Two Numbers

Python Program Prime Between Two Numbers In this Python programming tutorial we shall learn to write and execute a Python program to print all the prime numbers between the two given  numbers. Program statement: Write a Python program to input two numbers and print all the prime numbers between these two numbers. Actually we want… Read More »

Loading

Python Program Digits Product

In this tutorial we shall learn to write a Python program to print product that is multiplication of digits of a given number. Program statement: Write a program to display product of the digits of a number accepted from the user. How this Python Program Product of digits Works? Dear readers, when we divide a… Read More »

Loading

Python Prime Factors Program

Python Prime Factors Program – This Python program will take a number as input from the user. It will display prime factors of that number. We will study prime factors before writing the Python program to find them. Definition of Prime Factor A factor that is a prime number is called a Prime Factor. We… Read More »

Loading

Python Program To Print a to z using for loop and chr function

Topic: Python Program To Print a to z using for loop and chr() function We will use the built-in Python function chr() to print the small alphabets from a to z. We know that the Ascii code of ‘a’ is 97 and that of ‘z’ is 122. Therefore we will use a range() function in… Read More »

Loading