Category Archives: Basic Programs in Python

Python Program Quadratic Equation Roots

Task: Python Program Quadratic Equation Roots, Solution of Quadratic equation, Find roots of quadratic equation. How This Program Works This program uses cmath module and sqrt() builtin function to find the roots of the given quadratic equation when the coefficients a,b and c are given. The popular quadratic equation formula for solving it is as… Read More »

Loading

Python Convert Decimal to Binary Octal Hexadecimal

Task: Python Convert Decimal to Binary Octal Hexadecimal How this Program Works? This Python program will perform number convertion using builtin Python functions. It uses builtin Python functions for number system conversion: bin(int_number) oct(int_number) hex(int_number) Python bin() Function The Python bin() function converts an integer number to a binary string prefixed with 0b . For… 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

Python Recursive Function Check Palindrom String

Python Recursive Function Check Palindrom String # Write a Python program to # input a string and find # whether the string is a palindrome or not # www.easycodebook.com # Start of the Python program # define the recursive function def is_palindrome(s): if len(s) <= 1: # Base case return True elif s[0] != s[len(s)… Read More »

Loading

Python Insertion Sort Program using Array

Python Insertion Sort Program using Array # Write a Python program insertion sort # to input n numbers in # python array and sort them # in ascending order using insertion sort algorithm # Perfect Python Programming Tutorials # Author : www.EasyCodebook.com (c) import array # define a function for insertion sort def insertion_sort(arr): for… Read More »

Loading

Python Array Module Selection Sort Program

Python Array Module Selection Sort # Write a Python program # to input n numbers in # python array and sort them # in ascending order using selection sort algorithm # Perfect Python Programming Tutorials # Author : www.EasyCodebook.com (c) import array # define a function selection_sort() def selection_sort(arr): n = len(arr) for i in… Read More »

Loading