Found 34494 Articles for Programming

Find the text of the given tag using BeautifulSoup

Atharva Shah
Updated on 21-Aug-2023 16:10:10

3K+ Views

BeautifulSoup is a powerful tool that makes it easy to extract information from HTML and XML documents primarily developed in Python for the purpose of web scraping and web data extraction. One of the most useful features of BeautifulSoup is the ability to find specific tags within a document. In this blog, we will explore how to use BeautifulSoup to find the text of a given tag along with a few examples. Installation and Syntax Installing BeautifulSoup is necessary before using it so use the Python package manager and run the following command right inside your terminal. pip install beautifulsoup4 ... Read More

Find the tag with a given attribute value in an HTML document using BeautifulSoup

Atharva Shah
Updated on 21-Aug-2023 15:17:58

273 Views

Extracting data from HTML pages is a typical activity during web scraping. Many tags and characteristics found in HTML pages aid in locating and extracting pertinent data. A well-known Python module named BeautifulSoup may be used to parse HTML texts and extract useful information. In this tutorial, we'll concentrate on utilizing BeautifulSoup to locate a tag that has a specific attribute value. Installation and Setup In order to start, we must install BeautifulSoup. Pip, Python's package installer, may be used for this. The following command should be entered into a command window or terminal − pip install beautifulsoup4 After ... Read More

Find the sum and product of a NumPy array elements

Atharva Shah
Updated on 21-Aug-2023 15:13:05

308 Views

A Python package called NumPy is employed in scientific computing and to handle large-scale numerical data. It provides support for multi-dimensional arrays and matrices, as well as a large library of mathematical functions to manipulate them. In this tutorial, we will focus on two of the most commonly used NumPy functions: sum() and prod(). These functions are used to calculate the sum and product of all the elements in a NumPy array, respectively. Installation Get the numpy package installed using pip inside your terminal pip install numpy Import it as highlighted after successful installation − import numpy as np ... Read More

How to add Site Header, Site Title, Index Title in a Django Project?

Atharva Shah
Updated on 21-Aug-2023 15:10:42

380 Views

To make it simple for people to browse and comprehend the goal of the site, it's critical to have a clear and succinct site header, site title, and index title when constructing a Django project. You must specify the site header, site title, and index title in your Django application's HTML templates in order to add them to the site. Every page of your website will have these components, making it simpler for visitors to browse and comprehend the goal of your project. These additions are especially helpful for complicated, huge websites that users may have trouble navigating. We will ... Read More

How to add RSS Feed and Sitemap to Django project?

Atharva Shah
Updated on 21-Aug-2023 15:09:35

93 Views

Introduction The incorporation of web components like Sitemaps and RSS (Really Simple Syndication) Feeds can provide a multitude of benefits such as enhancing user accessibility, augmenting website content consumption, and improving search engine performance. Developers can leverage Django to streamline the process of constructing web applications, resulting in the creation of websites that are exceptionally effective and user-friendly. What is RSS and Sitemap? RSS Feeds are XML files that include summaries of the material on a website, like article headlines and descriptions. Users may simply get the material without visiting the website by reading these files using RSS readers. On ... Read More

Toggle First and Last Bits of a Number

Vanshika Sood
Updated on 17-Aug-2023 20:02:03

436 Views

The following article provides an in depth explanation of the method used to modify a number by toggling its first and last bit using bitwise operators. A bitwise operator is an operator that can be used to manipulate individual bits in binary numbers or bit patterns. Problem Statement For a given number n, modify the number such that the first and the last bit of the binary expansion of the new number are flipped i.e. if the original bit is 1 then the flipped bit should be 0 and vice versa. All the bits between the first and the last ... Read More

The Sum of the Fifth Powers of the First n Natural Numbers

Vanshika Sood
Updated on 17-Aug-2023 20:00:47

380 Views

Natural numbers are numbers that start from 1 and include all the positive integers. The following article discusses two possible approaches to compute the sum of the fifth powers of the first n natural numbers. The article discusses the two approaches in detail and compares them with regards to efficiency and intuitiveness. Problem Statement The purpose of this problem is to compute the arithmetic sum of the first n natural numbers, all raised to their fifth power i.e. $\mathrm{1^5 + 2^5 + 3^5 + 4^5 + 5^5 + … + n^5}$  till the nth term. Examples Since n is a ... Read More

Set the Leftmost Unset Bit

Vanshika Sood
Updated on 27-Oct-2023 15:56:21

269 Views

This article seeks a method for setting a given number's leftmost unset bit. The first unset bit after the most significant set bit is considered the leftmost unset bit. Problem Statement Given a number n, the task is to set the left most bit of the binary expansion of the number that is unset. All the other bits should be left unchanged. If all the bits of the original number are already set, return the number. Examples Input: 46 Output: 62 Explanation Binary Expansion of 46 = 101110. Left most unset bit is 101110. Upon setting the underlined ... Read More

Pernicious Number

Vanshika Sood
Updated on 17-Aug-2023 19:47:00

109 Views

A number is considered to be pernicious if the number is a positive integer and the number of set bits in its binary expansion are prime. The first pernicious number is 3, as 3 = (11)2. It can be seen that the number of set bits in the binary representation of 3 are 2, which is a prime number. The first 10 pernicious numbers are 3, 5, 6, 7, 9, 10, 11, 12, 13, 14. Interestingly, powers of 2 can never be pernicious since they always have only 1 set bit. 1 is not a prime number. On the other ... Read More

Odious Number

Vanshika Sood
Updated on 17-Aug-2023 19:40:24

190 Views

A number is considered to be an odious number if it has an odd number of 1s in its binary expansion. The first 10 odious numbers are 1, 2, 4, 7, 10, 11, 13, 14, 16, 19, 21. Interestingly, all powers of 2 are odious since they have only 1 set bit. The following article discusses 2 approaches in detail to find whether a number is an odious number or not. Problem Statement This problem aims to check whether the given number is an odious number i.e. it is a positive number with an odd number of set bits in ... Read More

Advertisements