Found 10476 Articles for Python

Python Program to Get Sum of N Armstrong Numbers

Saba Hilal
Updated on 10-Jul-2023 15:46:46

198 Views

A number is said to be an Armstrong number if the digits are taken individually and raised to the power of the total digits and then these subparts are added together and they give the number itself. Here, in this Python example, using two different examples, the method of finding the total sum of n-digit Armstrong numbers is given. In example 1, the method to calculate the sum of all the 3 digit Armstrong numbers is given. In example 2, the number of digits can be decided by the user at runtime. This program is tested using digit values 4 ... Read More

Python Program to find Sum of Negative, +ve Even and +ve Odd numbers in a List

Saba Hilal
Updated on 10-Jul-2023 15:41:43

768 Views

Sometimes the task is to separate the negative and positive numbers or to separate the odd numbers and even numbers from a list of integers. Here, in this Python article, both these tasks are done. First negative numbers are separated into another list. Then the positive odd and positive even numbers are separated into separate lists. To calculate the sum, the numbers from these negative number lists, positive odd number lists, and positive even number lists are taken to calculate sums separately. In the two different examples, the main list of integers is formed. In example 1, the negative and ... Read More

Python Program to Find Numbers Divisible by 7 and Multiple of 5 in a Given Range

Saba Hilal
Updated on 10-Jul-2023 15:38:57

1K+ Views

A multiple of a number n is also divisible by the same number n. If a number M is a multiple of a number n, then if we divide M by n, its remainder must be zero. Also to create the multiples of number n within a given range, we can add n multiple times and check that the resulting number is within the given range or not. Another way to make multiples of a given number n, within a given range, is to find the first multiple in the given range for n and then to find the value ... Read More

Python program to find the string weight

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

781 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

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

201 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

350 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

Extracting locations from text using Python

Rohan Singh
Updated on 10-Jul-2023 13:44:30

3K+ Views

In Python, we can extract location from text using NLP libraries available in Python such as NLTK, spaCy, and TextBlob.Extracting location from text is used in various Natural language processing tasks such as sentiment analysis, information retrieval, and social media analysis. In this article, we will discuss how we can extract location from text using the spaCY library. Prerequisites Installing spaCY library Before using the scpaCy library for the extraction process you need to install the spaCy library using pip command in Python. To extract the spaCy library you can type the following command in your terminal or ... Read More

Extracting an attribute value with beautiful soup in Python

Rohan Singh
Updated on 10-Jul-2023 13:41:53

9K+ Views

To extract an attribute value with the help of Beautiful Soup we need to parse the HTML document and then extract the required attribute value. Beautiful Soup is a Python library that is used to parse HTML and XML documents.BeautifulSoup provides several methods to search and navigate the parse tree, making it easy to extract data from the documents. In this article, we will extract attribute values with the help of Beautiful Soup in Python. Algorithm You can follow the below-given algorithm to extract attribute values with beautiful soup in Python. Parse the HTML document using the BeautifulSoup ... Read More

Extract the title from a webpage using Python

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

5K+ Views

In Python, we can extract the title from a webpage using Web scraping. Web scraping is the process of extracting data from a website or webpage. In this article, we will scrap the title of a webpage using the Requests and BeautifulSoup libraries in Python. Extracting Title from Webpage Method 1: Using Request and Beautiful Soup libraries We can use the request and Beautiful Soup libraries of Python to extract titles from a webpage. The requests library is used to send HTTP requests to a website and get its response. We then use the response object to extract the HTML ... Read More

Advertisements