Find String Weight in Python

Saba Hilal
Updated on 10-Jul-2023 15:29:07

808 Views

In this article, the given task is to find the total string weight. To calculate the string weight, we have converted the given strings into the lower form. Considering the weight of the characters, we have taken a=1, b=, 2 and so up to z=26. In this Python article, using two different examples, the approaches to find the given string’s weight are given. In the first example, given characters in a string are fetc, hed, and then their respective weight is added to the updated weight. In example 2, first the frequency of occurrence of a given character in the ... Read More

Golang Program for Right View of Binary Tree

Aman Sharma
Updated on 10-Jul-2023 15:12:35

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 right view of a binary tree. If we try to understand the problem statement more than what exactly the right view is then we can explain it in a way that all the nodes are visible when you see them by standing on the right 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 right side ... Read More

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

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

Faulty Calculator Using Python

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

292 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

Fatman Evolutionary Model in Social Networks

Rohan Singh
Updated on 10-Jul-2023 14:12:15

1K+ Views

The Fatman model is a model that explains how social media grows and changes over time. Social Media has become an integral part of everyone’s life. Researchers are constantly trying to understand the social media growth and behavior associated with it. In this article, we will understand the Fatman model and its significance in social media network Analysis. Fatman Model The Fatman model was first introduced by Alain Barrat, Marc Barthélemy, and Alessandro Vespignani in a paper published in 2004. Fatman's model says that the growth of social networks is influenced by two main factors − Preferential Attachment ... Read More

Fastest Way to Convert Integers to Strings in Pandas DataFrame

Rohan Singh
Updated on 10-Jul-2023 14:07:07

4K+ Views

In Python there are many methods to convert Integers to strings in Pandas Dataframe like astype() method, apply() method, map() method, list comprehension, etc. Out of all these methods, the fastest way to convert Integers to string in Pandas data frame can be determined by tracking the time taken by each method for conversion. In this article, we will understand how to convert integers to string in a pandas data frame using all four methods and then track the time taken by each for conversion. Method 1: Using the List comprehension method In this method, we create a list of ... Read More

Facts App Using Tkinter Module

Rohan Singh
Updated on 10-Jul-2023 14:03:46

217 Views

In Python, we can use Tkinter module and randfacts module to create a Facts generator App. Tkinter is a Python GUI toolkit that is used to create graphical applications. You can create buttons, labels, text boxes, and other types of widgets using the Tkinter library. The randfacts is a Python module that generates random facts. In this article, we will implement a Fact App Generator GUI application using Tkinter and the randfacts module. Creating the Facts Generator App To create the facts generator app we first need to install the randfacts module using the Python package manager. To install ... Read More

Facts About Cython Programming Language

Rohan Singh
Updated on 10-Jul-2023 13:58:37

373 Views

Cython is a programming language that is a superset of Python and can be compiled into C code for improved performance. Cython is developed to improve the execution speed and make the code faster compared to Python. In this article, we will look at some interesting facts about Cython Programming Language. Cython can be used to speed up Python code As the name suggests Cython is Python-like code that can be converted to C code for faster and improved execution speed. Developers can write code in Python which is then compiled into C code and makes the language much faster. ... Read More

Extract Real and Imaginary Parts of a NumPy Array of Complex Numbers

Rohan Singh
Updated on 10-Jul-2023 13:54:00

6K+ Views

In Python, we can extract the real and imaginary parts of a NumPy array of the complex number using the real and imag attributes of the array, respectively. Numpy is a Python library that is used for complex calculations and also provides support for complex numbers. In this article, we will understand how we can extract the real and imaginary parts separately of a complex number. Understanding Complex Number in Numpy In Numpy we represent a complex number as a combination of the real and imaginary parts using the complex data type. We can create a complex number in ... Read More

Advertisements