Blog

python tutorials and learn python

Created with Sketch.

 Python program to print the elements of an array in reverse order

 Python program to print the elements of an array in reverse order In this program, we need to print the elements of the array in reverse order that is; the last element should be displayed first, followed by second last element and so on.       ALGORITHM: STEP 1: Declare and initialize an array.…
Read more

Python program to print the elements of an array

Python program to print the elements of an array This is a simple program to create an array and then to print it’s all elements. Now, just know about arrays. Arrays are the special variables that store multiple values under the same name in the contiguous memory allocation. Elements of the array can be accessed…
Read more

Python program to print the duplicate elements of an array

Python program to print the duplicate elements of an array In this program, we need to print the duplicate elements present in the array. This can be done through two loops. The first loop will select an element and the second loop will iteration through the array by comparing the selected element with other elements.…
Read more

Python program to left rotate the elements of an array

Python program to left rotate the elements of an array In this program, we need to rotate the elements of an array towards the left by the specified number of times. In the left rotation, each element of the array will be shifted to its left by one position and the first element of the…
Read more

Python program to find the frequency of each element in the array

Python program to find the frequency of each element in the array In this program, we have an array of elements to count the occurrence of its each element. One of the approaches to resolve this problem is to maintain one array to store the counts of each element of the array. Loop through the…
Read more

Python program to copy all elements of one array into another array

Python program to copy all elements of one array into another array In this program, we need to copy all the elements of one array into another. This can be accomplished by looping through the first array and store the elements of the first array into the second array at the corresponding position. ARRAY 1…
Read more

Python Program to Remove Punctuation from a String

Python Program to Remove Punctuation from a String Punctuation: The practice, action, or system of inserting points or other small marks into texts, in order to aid interpretation; division of text into sentences, clauses, etc., is called punctuation. -Wikipedia Punctuation are very powerful. They can change the entire meaning of a sentence. See this example:…
Read more

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