Category Archives: Python Function Programs

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 Program To Print Nth Fibonacci Series Term

Python Program To Print Nth Fibonacci Series Term – You can write a Python program to print the Nth Fibonacci term using a simple iterative approach. Here’s an example: Source Code def nth_fibonacci(n): if n <= 0: return “N should be a positive integer.” elif n == 1: return 0 elif n == 2: return… Read More »

Loading

Python Program Convert Gallons To Litres Using Function

Python Program Convert Gallons To Litres – To convert gallons to liters in Python, you can use the following simple program. The conversion factor is 1 US gallon = 3.78541 liters. This program defines a function gallons_to_liters that takes the number of gallons as input and returns the equivalent amount in liters. It then takes… Read More »

Loading

Python GCD Recursive Function

Python GCD Recursive Function – Write a Python Program to find GCD of two numbers by recursion. Python GCD Recursive Function Python Program GCD of Two Numbers # Write a Python Program to find GCD # of two numbers using Recursion # define a recursive GCD function def recursive_gcd(a,b): if(b==0): return a else: return recursive_gcd(b,a%b)… Read More »

Loading

Python Convert Millimeters to Inches using Function

Python Convert Millimeters to Inches using function – This Python program will input millimeters  from the user. It will convert mm into inches. The Formula To Convert mm into Inches To convert millimeters into inches, Multiply millimeters by 0.0393701 or divide millimeters by 25.4. Source Code – Python Function To Convert mm to Inches #Python… Read More »

Loading

Python File Phonebook Program

Topic: Python file Phonebook Python file Phonebook Program: Write a Python Program using text files to create and maintain a Phone Book. Python Phone book Program uses file to provide the following functions: You can add new contact records It will display all the contact records stored already Search function will provide you the searching… Read More »

Loading

Python Print Birthday Poem Program

Python Print Birthday Poem Program for printing the popular happy birthday poem to a specific person. This Python program uses a user defined function print_birthday_poem(person_name). This function takes a person name as parameter and prints happy birthday poem for him / her. The main function will ask the input that is the birthday person’s name.… Read More »

Loading