Found 26504 Articles for Server Side Programming

Golang Program Level Order Traversal of Binary Tree

Aman Sharma
Updated on 10-Jul-2023 17:20:06

530 Views

In programming, there are different data structures to store data. There are two different types of data structures linear and non −linear. Array, stack, queue, and linked list are linear data structures. Binary trees, trie, etc are non − linear data structures. In this article, we are going to explore level order traversal on one of the non − linear data structures i.e. binary tree. Level Order Traversal In level order traversal, of a binary tree we start from the root node and then traverse the children nodes and move to the children of children nodes. In this way, ... Read More

Golang Program Left View of Binary Tree

Aman Sharma
Updated on 10-Jul-2023 17:17:31

211 Views

In programming, there is a coding problem of binary tree that gets asked very frequently in interviews and the problem statement is to find the left view of a binary tree. If we try to understand the problem statement more than what exactly the left view is then we can explain it in a way that all the nodes are visible when you see them by standing on the left side of the tree. Illustration Let us understand more with the help of an example. Suppose we have a below tree and if we stand on the left side ... Read More

Golang program Breadth-First Search graph

Aman Sharma
Updated on 10-Jul-2023 17:15:46

2K+ Views

Graph is a data structure that consists of edges or we can say nodes and vertices. Vertices are the lines between the nodes. To traverse all these nodes we have different traversal algorithms. In this article, we will discuss, Breadth − first search or we can say BFS. In Breadth − first search, we first start from one node and move to another till the dead end comes. Example If we start from node 1 then it will first visit node 2 and node 4 first. Then from node 2, we will visit node 3. In this way, the ... Read More

How to Replace Values in Columns Based on Condition in Pandas

Rohan Singh
Updated on 10-Jul-2023 14:21:50

9K+ Views

In Python, we can replace values in Column based on conditions in Pandas with the help of various inbuilt functions like loc, where and mask, apply and lambda, etc. Pandas is a Python library that is used for data manipulation and work with structured data. In this article, we will replace values in columns based on conditions in Pandas. Method 1: Using loc The loc function is used to access a group of rows and columns in a DataFrame. We can use this function to replace values in a column based on some condition. Syntax df.loc[row_labels, column_labels] The loc ... Read More

Faulty calculator using Python

Rohan Singh
Updated on 10-Jul-2023 14:13:42

272 Views

A faulty calculator in Python is a calculator that gives incorrect results for certain calculations. In Python, we can create our own calculator and use it for doing mathematical calculations. If we want to create a faulty calculator we need to create or introduce errors in the functions that perform the calculations. In this article, we will create a faulty calculator using Python. Creating a faulty Calculator Creating a faulty calculator is easy as we need to just introduce some incorrect calculations in the normal calculator in the code to give an incorrect result which converts it into a ... Read More

How to replace a word in Excel using Python?

Rohan Singh
Updated on 10-Jul-2023 14:17:35

2K+ Views

In Python, we can replace a word in Excel with another word using a third-party Python library called openpyxl. Microsoft Excel is a useful tool that is used for managing and analyzing data. Using Python we can automate some of the Excel data management tasks. In this article, we will understand how we can replace a word in Excel using Python. Installing openpyxl Before implementing the program to replace Word in Excel we need to install the openpyxl library in our system using the Python package manager. To install openpyxl type the following command on your terminal or command ... Read More

Python Program to Find the Number of Unique Words in Text File

Saba Hilal
Updated on 10-Jul-2023 17:07:13

4K+ Views

In this article, the given task is to find the number of unique words in a text file. In this Python article, using two different examples, the approaches to finding the unique words in a text file and their count are given. In the first example, given words from a text file are fetched, and then their unique set is made before counting these unique words. In example 2, first the list of words is created, then it is sorted. After this from this sorted list, the duplicates are removed and finally, the unique word left in the file ... Read More

Python program to find the frequency of the elements which are common in a list of strings

Saba Hilal
Updated on 10-Jul-2023 17:03:58

198 Views

In this Python article, the given task is to get the frequency of the elements which are common in a list of strings. Sometimes the list to be analyzed using Python is available in an Excel file. To get this list from Excel, a module called openpyxl is used. In this Python article, using three different examples, the ways of getting the frequency of the items which are repeated in a list of strings are given. In example 1, the frequency of the characters which are common in a list of strings is found. In the next two examples, ... Read More

Python Program to Find Sum of First and Last Digit

Saba Hilal
Updated on 10-Jul-2023 16:51:14

1K+ Views

In this article, the given task is to add the first and the last digit of an integer. Now the integer can be very small or it can be a big number. So, these programs will have two parts. First, we need to find how big the integer is and then get the first digit from it. The second part will be to get the last number from the given integer which can be done easily by dividing the number by ten and finding the remainder. In this Python article, using four different examples, the approaches to adding the first ... Read More

Python program to print positive numbers in a list

Saba Hilal
Updated on 10-Jul-2023 16:23:30

587 Views

In this article, the task is to print the positive numbers from a list of integers. Here, in this Python article, this task is done using the different methods in 4 different examples. Then these positive numbers are printed. In example 1, the positive numbers are picked and separated into another list. In the example 2, all the elements that are not positive are removed. In example 3, the sorted list is split up to zero and only positives are retained. In example 4, filter is used to select the positive numbers. Example 1 - Select only the positive numbers ... Read More

Advertisements