Category: Python Programs

python tutorials and learn python

Created with Sketch.

Python Program to Sort Words in Alphabetic Order

Python Program to Sort Words in Alphabetic Order Sorting: Sorting is a process of arrangement. It arranges data systematically in a particular format. It follows some algorithm to sort data. See this example: my_str = input(“Enter a string: “) # breakdown the string into a list of words words = my_str.split() # sort the list words.sort() # display the sorted words for word in words:    print(word) my_str = input(“Enter a string: “)<br /><br /> # breakdown the string into a…
Read more

Python Program to Transpose a Matrix

Python Program to Transpose a Matrix Transpose Matrix: If you change the rows of a matrix with the column of the same matrix, it is known as transpose of a matrix. It is denoted as X’. For example: The element at ith row and jth column in X will be placed at jth row and…
Read more

Python Program to Multiply Two Matrices

Python Program to Multiply Two Matrices Matrix multiplication is a fundamental operation in linear algebra. In this blog post, we’ll explore how to write a Python program to multiply two matrices. We’ll discuss the algorithm involved and provide a complete Python code example with output. Matrix Multiplication Algorithm: Matrix multiplication follows a specific algorithm where…
Read more

Python Program to Add Two Matrices

Python Program to Add Two Matrices What is Matrix? In mathematics, matrix is a rectangular array of numbers, symbols or expressions arranged in the form of rows and columns. For example: if you take a matrix A which is a 2×3 matrix then it can be shown like this: 2       3          5 8       12        7 2 3 5<br />…
Read more

Python Program to Find Factorial of Number Using Recursion

Python Program to Find Factorial of Number Using Recursion Factorial: Factorial of a number specifies a product of all integers from 1 to that number. It is defined by the symbol explanation mark (!). For example: The factorial of 5 is denoted as 5! = 1*2*3*4*5 = 120. See this example: def recur_factorial(n):    if n == 1:        return n    else:…
Read more

Python Program to Display Fibonacci Sequence Using Recursion

Python Program to Display Fibonacci Sequence Using Recursion Fibonacci sequence: A Fibonacci sequence is a sequence of integers which first two terms are 0 and 1 and all other terms of the sequence are obtained by adding their preceding two numbers. For example: 0, 1, 1, 2, 3, 5, 8, 13 and so on… See…
Read more

Python Function to Display Calendar

Python Function to Display Calendar In Python, we can display the calendar of any month of any year by importing the calendar module. See this example: # First import the calendar module import calendar # ask of month and year yy = int(input(“Enter year: “)) mm = int(input(“Enter month: “)) # display the calendar print(calendar.month(yy,mm)) # First import the calendar module<br /> import calendar<br /> # ask of month and year<br /> yy = int(input(“Enter year: “))<br…
Read more

Python Program to Make a Simple Calculator

Python Program to Make a Simple Calculator In Python, you can create a simple calculator, displaying the different arithmetical operations i.e. addition, subtraction, multiplication and division. The following program is intended to write a simple calculator in Python: See this example: # define functions def add(x, y):    “””This function adds two numbers””    return x + y def subtract(x, y):    “””This function subtracts two numbers“””    return x – y def multiply(x, y):    “””This function multiplies two numbers“””    return x * y def divide(x, y):    “””This function divides two numbers”””    return x / y # take input from the user…
Read more

Python Program To Find ASCII value of a character

Python Program To Find ASCII value of a character ASCII: ASCII is an acronym stands for American Standard Code for Information Interchange. In ASCII, a specific numerical value is given to different characters and symbols, for computers to store and manipulate. It is case sensitive. Same character, having different format (upper case and lower case)…
Read more

Python Program to Convert Decimal to Binary, Octal and Hexadecimal

Python Program to Convert Decimal to Binary, Octal and Hexadecimal Decimal System: The most widely used number system is decimal system. This system is base 10 number system. In this system, ten numbers (0-9) are used to represent a number. Binary System: Binary system is base 2 number system. Binary system is used because computers…
Read more