One of the very common problems in any programming language is how to reverse a String. Let’s see a few ways to do this in python. 1. Using String Slicing well first of all the most easy way.. Here we…
Category: basic
Python Program to Check if a number is FIbonacci
In Fibonacci Sequence, every previous two numbers gives the next number. the first 10 Fibonacci numbers: 0, 1, 1, 2, 3, 5, 8, 13, 21, 35 In this python Program we will see how to test if a number given…
Python Program to check if a number is Perfect Square
A number that can be expressed as the product of two equal integers is a Perfect Square number. for example: 25 can be expressed as 5 x 5 In the given python3 code we take a user input and take…
Python Program to Generate Fibonacci Series using Recursion
Fibonacci Series: A sequence of numbers in which each number is the sum of the previous two numbers. First 10 Fibonacci numbers: 0,1,1,2,3,5,8,13,21,34,… In the following python program we have used recursive function to find out the Fibonacci series up…
Python Program to find frequency of Characters in a String
We will find the count of repeating characters in a string using python3. Here we have used dictionary data structure to make a key-value pair for all alphabets and numbers, where the key is the alphabet or number and value…
Python Program for Linear Search using For loop
In linear search algorithm we match the element to be searched with the entire list of elements. Therefore its a brute force approach. time complexity: O(n) Linear Search implementation in Python: list_of_elements = [4, 2, 8, 9, 3, 7]x =…
Python Program to Convert Decimal to Binary
Using Loop To convert Decimal to binary we check if the number is divisible by 2, if yes then we take a string and append 0 to and and if not then append 1 to it and divide the number…
Python Program to find HCF and LCM
HCF is also called Greatest Common divisor (GCD).the HCF of two or more number is the largest of all the common factors. for example:if we take two numbers, 12 and 18their common divisor are 1,2,3 and 6. therefore 6 being…
Python Program for Binary Search with explanation
Binary search algorithm is used to find a number in a sorted list. so, the pre condition for binary search is that the list should be sorted. If the number is found then its index is returned. This algorithm works…
Python Program to reverse a number using loop
Here is a simple program to find the reverse of an entered number. Please note that this program works for only positive integers. Source Code: x = input(“Please Enter a number to reverse: “)reverse = 0while(x): reverse = reverse…