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: Python Program Quadratic Equation Roots »

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: Python Convert Decimal to Binary Octal Hexadecimal »

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: Python Program To Print a to z using for loop… »

Loading

Python Program Find Minimum Number From List

Topic: Python Program Find Minimum Number From List using prefefined min() function. # Python program to find smallest # number in a list def main(): # create empty list so that user will input at runtime number_list = [] # ask the user to input n / how many numbers? num = int(input(“How many numbers… Read More: Python Program Find Minimum Number From List »

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: Python Recursive Function Check Palindrom String »

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: Python Insertion Sort Program using Array »

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: Python Array Module Selection Sort Program »

Loading

Python Bubble Sort using Array Module

Python Bubble Sort using Array Module # Write a Python program # to input n numbers in # Python array and sort them using # bubble sort # Perfect Python Programming Tutorials # Author : www.EasyCodebook.com (c) import array def bubbleSort(arr): n = len(arr) for i in range(n): for j in range(0, n-i-1): if arr[j]… Read More: Python Bubble Sort using Array Module »

Loading

Python Print Grade From Score if elif else

Python Print Grade From Score if elif else # Write a Python program # using if-elif-else to print # the grade based on # score input by the user # Perfect Python Programming Tutorials # Author : www.EasyCodebook.com (c) # Actual Program starts here # Python Program – Print Your Grade using if-elif-else score =… Read More: Python Print Grade From Score if elif else »

Loading