## Python Programs | Python Programming Examples## IntroductionThe Python is most high-demanded programming language among other programming languages because it is simple as well as flexible to use, and easy to understand. This extensive collection of the libraries and the frameworks offers the perfect wide range of applications to come up with the web development and the scientific computing. The dynamism of Python is the focus of this article as we discuss several applications of it; here you will find programs that can be created with its help. ## What is the Python Programming Language?Unlike many other programming languages, Python is well known for its simplicity and readability due to having a ## What is a Program?A program, in the realm of programming languages of computer science and software development, is a definition of a Lets see the list of Python programs from basics to advanced in the entire tutorial. ## Python Basic Programs- Python program to print "Hello Python"
- Python program to do arithmetical operations
- Python program to find the area of a triangle
- Python program to solve quadratic equation
- Python program to swap two variables
- Python program to generate a random number
- Python program to convert kilometers to miles
- Python program to convert Celsius to Fahrenheit
- Python program to display calendar
- Python Program to Check if a Number is Positive, Negative or Zero
- Python Program to Check if a Number is Odd or Even
- Python Program to Check Leap Year
- Python Program to Check Prime Number
- Python Program to Print all Prime Numbers in an Interval
- Python Program to Find the Factorial of a Number
- Python Program to Display the multiplication Table
- Python Program to Print the Fibonacci sequence
- Python Program to Check Armstrong Number
- Python Program to Find Armstrong Number in an Interval
- Python Program to Find the Sum of Natural Numbers
- Python Program to Print Reverse of a String
- Python Program to Print Sum of First Ten Natural Numbers
In the next section we will see the list of programs based on functions. Before we going to see the list of programs based on functions l, let us know what is a function. ## What is a Function in Python?In the field of computer science, a function is a code that has a self contained block of code and performs a concrete job or operation. Abilities of functions are made to divide program into modules and they are reusable, this makes programming more readable, concise and convenient to debug. ## Python Function Programs- Python Program to Find LCM
- Python Program to Find HCF
- Python Program to Convert Decimal to Binary, Octal and Hexadecimal
- Python Program To Find ASCII value of a character
- Python Program to Make a Simple Calculator
- Python Program to Display Calendar
- Python Program to Display Fibonacci Sequence Using Recursion
- Python Program to Find Factorial of Number Using Recursion
- Python Program to Calculate the Power of a Number
In the next section, we will see the some of number programs. ## Python Number Programs- Python program to check if the given number is a Disarium Number
- Python program to print all disarium numbers between 1 to 100
- Python program to check if the given number is Happy Number
- Python program to print all happy numbers between 1 and 100
- Python program to determine whether the given number is a Harshad Number
- Python program to print all pronic numbers between 1 and 100
- Python program to print first ten natural numbers.
- Python Progran to check an Armstrong number or not
In the next section, we will see the programs based on arrays. Before we going to see programs of an array, lets know the what is an array. ## What is an Array?An array, one of the most important elements, is used in computer science as a fundamental data structure in which a collection of elements is stored in the contagious memory locations and all these data are usually of one type. The arrays give the chance to grouped and access data in a consecutive chunk of memory space. They can be accessed through their indices or positions in the array. Let's see the list of programs based on an arrays below: ## Python Array Programs- Python program to copy all elements of one array into another array
- Python program to find the frequency of each element in the array
- Python program to left rotate the elements of an array
- Python program to print the duplicate elements of an array
- Python program to print the elements of an array
- Python program to print the elements of an array in reverse order
- Python program to print the elements of an array present on even position
- Python program to print the elements of an array present on odd position
- Python program to print the largest element in an array
- Python program to print the smallest element in an array
- Python program to print the number of elements present in an array
- Python program to print the sum of all elements in an array
- Python program to right rotate the elements of an array
- Python program to sort the elements of an array in ascending order
- Python program to sort the elements of an array in descending order
- Python Program to Merge Two Arrays into a Single Array
- Python Program to Insert an Element into an Array
- Python Program to Delete an Element from an Array
In the next section, we will see the list of pythons programs based matrix. Before we going to see the list of matrix programs, Let us first know the what is a matrix. ## What is a Matrix?In Computer Science, a matrix is an abbreviation of a two dimensional array, where the elements are retrieved via providing both horizontal and vertical indices or coordinates. Matrices are being used in the areas like computer graphics, machine learning, and numerical simulations for example image processing, coarse-grained data analysis, and solving systems of equations. Let's see the list of python programs based on Matrix below: ## Python Matrix Programs- Python Program to Add Two Matrices
- Python Program to Multiply Two Matrices
- Python Program to Transpose a Matrix
- Python Program to Perform Matrix Rotation
- Matrix Concatenation Program
- Python Program to Print Inverse of a Matrix
- Matrix Rank Calculation
In the next section we will see the list of python programs based on Strings. Before we going to see list of python programs based on Strings l, let us first know what is a String. ## What is a String?In the programmes of computers, "string" is known as a series of character(s), mostly used for the representation of the texts. Impressively, most programming languages, including Python, have a choice of using either single quote (') or double quote (").For example: Now we will see the list of python programs based on Strings below. ## Python String Programs- Python Program to Sort Words in Alphabetic Order
- Python Program to Remove Punctuation From a String
- Python Program to reverse a string
- Python Program to convert list to string
- Python Program to convert int to string
- Python Program to concatenate two strings
- Python Program to generate a Random String
- Python Program to convert Bytes to string
- Python Program to check whether given string is a palindrome or not
- Python Program to print length of a string
- Python Program to reverse the characters of a string
- Convert the string into lowercase to uppercase
- Convert the string into uppercase to lowercase
- Python Program to find the occurrence of a substring within a string
In the section, we will see the python Programs based on List. Before we going to see the python programs based on List, let's know what is a list in python. ## What is a List?From Python a "list" is a decked-out data structure that you can keep different items in and access them depending on the position. The support of the built-in data type, sequence of elements within square brackets [ ], is one of the many functions that sets Python apart. Such Lists can contain elements of mixed types, and these elements may be either numbers, strings, other lists or any other Python object. Here's an example of a simple list: Lists offer several important characteristics: **Ordered:**Agree to a list in which elements are added in order.**Mutable:**Near the end of the list, there is a very distinct portion to be altered once the whole list and all its items have been created. Therefore, you can append, change, or delete components of the list.**Allows Duplicates:**Sets cannot include similar elements.**Heterogeneous:**Lists have the ability to contain elements of different data types.**Dynamic:**List's dimension may change as and when elements are inserted or deleted thereof.
Below we will see the python Programs based on list. ## Python List Programs- Python Program to append element in the list
- Python Program to compare two lists
- Python Program to convert list to dictionary
- Python Program to remove an element from a list
- Python Program to add two lists
- Python Program to convert List to Set
- Python Program to convert list to string
- Python Program to remove duplicates from a list
- Python program to print length of a list
Python Program to sort the list in to the ascending or descending order In the next section we will see the list of programs on data structures. Before we going to see the list of programs based on data structures, let's first understand the data structures. ## What is a Data Structure?A data structure is a method of data storage in a computer where data is organized and arranged in a manner that allows the most effective access, modification, and processing. Data structures are used to structure and store data, providing users with functionality that enables fast searches and manipulation of information. ## Linear Data Structures:Non sequential structures such as linear data organization structures in accordance with the sequence order, where each element is positioned between its predecessor and successor. Examples include: - Arrays
- Linked Lists
- Stacks
- Queues
## Non-Linear Data Structures:Non-lineer data structures facilitate in arranging the elements in a more intricate way creating relationship other than just the purely sequential predecessor-successor quote. Examples include: - Trees
- Graphs
- Heaps
Let's see list of Programs based on Singly Linked List. ## Python Singly Linked List Programs- Python program to create a Singly Linked List of N nodes and count the number of nodes
- Python program to create a Singly Linked List of n nodes and display it in reverse order
- Python program to create and display a Singly Linked List
- Python program to delete a node from the beginning of the Singly Linked List
- Python program to delete a node from the end of the Singly Linked List
- Python program to delete a node from the middle of the Singly Linked List
- Python program to find the maximum and minimum value node from a Singly Linked List
- Python program to insert a new node at the beginning of the Singly Linked List
- Python program to insert a new node at the end of the Singly Linked List
- Python program to insert a new node at the middle of the Singly Linked List
- Python program to remove duplicate elements from a Singly Linked List
- Python program to search an element in a Singly Linked List
- Python program to sort the elements of the Singly Linked List
## Python Doubly Linked List Programs- Python program to convert a given binary tree to doubly linked list
- Python program to create a doubly linked list from a ternary tree
- Python program to create a doubly linked list of n nodes and count the number of nodes
- Python program to create a doubly linked list of n nodes and display it in reverse order
- Python program to create and display a doubly linked list
- Python program to delete a new node from the beginning of the doubly linked list
- Python program to delete a new node from the end of the doubly linked list
- Python program to delete a new node from the middle of the doubly linked list
- Python program to find the maximum and minimum value node from a doubly linked list
- Python program to insert a new node at the beginning of the Doubly Linked list
- Python program to insert a new node at the end of the Doubly Linked List
- Python program to insert a new node at the middle of the Doubly Linked List
- Python program to remove duplicate elements from a Doubly Linked List
- Python program to rotate doubly linked list by N nodes
- Python program to search an element in a doubly linked list
## Python Dictionary Programs- Python Program to create a dictionary
- Python Program to convert list to dictionary
- Python Program to sort a dictionary
- Python Program to Merge two Dictionaries
## Python Searching and Sorting Programs- Binary Search in Python
- Linear Search in Python
- Bubble Sort in Python
- Insertion Sort in Python
- Heap Sort in Python
- Merge Sort in Python
## Python Circular Linked List Programs- Python program to create a Circular Linked List of N nodes and count the number of nodes
- Python program to create a Circular Linked List of n nodes and display it in reverse order
- Python program to create and display a Circular Linked List
- Python program to delete a node from the beginning of the Circular Linked List
- Python program to delete a node from the end of the Circular Linked List
- Python program to delete a node from the middle of the Circular Linked List
- Python program to find the maximum and minimum value node from a circular linked list
- Python program to insert a new node at the beginning of the Circular Linked List
- Python program to insert a new node at the end of the Circular Linked List
- Python program to insert a new node at the middle of the Circular Linked List
- Python program to remove duplicate elements from a Circular Linked List
- Python program to search an element in a Circular Linked List
- Python program to sort the elements of the Circular Linked List
In the next section, we will see the list of programs based on Queue Data Structure. ## Programs Based on Queues- Python program to find the size of the queue
- Python program to add elements in the queue
- Python programs to delete elements from the queue
- Python program to print peek element from the queue
- Python program to check isFull() condition in a queue
- Python program to check isEmpty() condition in a queue
In the next section we will list of python programs based on stacks. ## Python Programs Based on Stack- Python program to perform push() operation
- Python program to perform pop() operation
- Python program to find length of the stack
- Python program to print peek element from the stack
In the next section we will see the programs on trees ## Python Programs Based on Trees- Python program to implement Binary Search Tree
- Python program to implement Balanced Binary Tree
- Python Program to implement AVL Trees
In the next section we will see the list of programs based on the graphs. Before going to see about the list of python programs based on the graphs, Let's first understand what is a graph. ## What is a Graph?A graph is a non-linear data structure comprised of a set of vertices (or points that might be alternatively referred to as nodes) that are connected by edges (or links and arcs). Graphs are often pictorially illustrated to represent the relations between two variables. It can be implemented as an equivalent of real-life network structures, either social networks, road nets, channel connections, etc. Here are some key components and characteristics of graphs:
A simple graph is made up of dots, or vertices. The graph is visually constructed from the vertices which are the entities such as the people in a social network, the cities in a road network, and the routers in a computer network.
Nodes of a graph represent the relationships or linkages between any two vertices. While the direction of relationships may be either directed, which means the relationship is one-way, or undirected, which means that the relationship is two-way. In a directed graph, for an edge, there is a directed flow or relationship attached to it, inducing an edge from one vertex to the other. In a graph that has no direction (undirected graph), edges represents a mutual relationship of two vertices.
Putting together the vertices in the graph with the connecting edges is known as a path. Links may depict bypasses, relationships or links between graph's elements.
A cycle in a graph is the steps of a path that commence at the same vertex and go through all the vertices and edges of a graph. ## Types of Graphs:Graphs can be categorized into various types based on their properties and characteristics, including: In the first graph (the directed graph), each node has an arrow that points to another node, expressing a certain relationship between them. In the second one, there are no arrows and the nodes are linked by lines expressing their relative position. Weighted Graphs and Unweighted Graphs; These are two types of graphs used in standard network topologies. - DAGs (DAGs refers to directed graphs with no cycles), and Cyclic Graphs are two very important graph categories.
- Bipartite Graphs
- Complete Graphs
Let us see some python programs based on graphs. ## Python Programs based on Graphs- Python program to implement Breath First Search
- Python program to implement Depth First Search
- Python program to find all connected components in an undirected graph using BFS or DFS
In the next section we will about algorithms and list of programs based on algorithms. ## What is an Algorithm?An algorithm is a set of steps scheduled and organized how to solve a problem or perform a certain computation. It is a description of a set of input data as well as the processing required to produce the desired result. The algorithms are in fact the main core behind the computer science as it is so efficient in solving numerous computation problems. ## Python Programs Based on Algorithms- Python program to implement Linear Search
- Python program to implement Binary Search
- Python program to implement Bubble Sort
- Python program to implement Insertion Sort
- Python program to implement Selection Sort
- Python program to implement Merge Sort
- Python program to implement Quick Sort
- Python program to Dijkstra's algorithm to find minimum spanning tree
- Python program to implement Prims Algorithm
- Python program to implement Kruskal's Algorithm
- Python program to implement greedy algorithm to solve Fractional Knap Sack
- Python program to solve coin change problem using greedy approach
- Python program to solve N-Queen problem
Next TopicPython Condition and Loops Programs |