Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Python Articles
Page 174 of 855
Find the least frequent element in an array using Python
Finding the least frequent element in an array is a common programming problem. Python offers several approaches: sorting with linear traversal, hashing with dictionaries, and using the Counter class from the collections module. Methods Overview The following methods can accomplish this task − Using sort() function (Naive Approach) Using Hashing with Dictionary Using Counter() Function Method 1: Using sort() Function This approach first sorts the array, then traverses it linearly to count frequencies. The time complexity is O(n log n) due to sorting. Example The following program returns the least frequent ...
Read MoreDecoding and encoding hexadecimal digitals using Python
In this article, we will learn how to decode and encode hexadecimal digits using Python. Python provides built-in modules like binascii and base64 that make hexadecimal conversion straightforward. What are Hexadecimal Digits? Hexadecimal is a base-16 number system that uses digits 0-9 and letters A-F to represent values. It's commonly used in programming to represent binary data in a more readable format. Method 1: Using binascii Module The binascii module provides functions to convert between binary and different ASCII-encoded binary representations. It's ideal when you need to encode or decode raw hex digit strings. Encoding ...
Read MoreDecimal Equivalents of 1/2, 1/3, . . . ,1/10 in Python
In this article, we will learn Python programs that calculate and display the decimal equivalents of fractions from 1/2, 1/3, 1/4, up to 1/10. We'll explore three different approaches to accomplish this task. Method 1: Basic Division for Single Fraction We can calculate the decimal equivalent of 1/2 using simple division. This demonstrates the basic concept before scaling to multiple fractions ? # Calculate decimal equivalent of 1/2 numerator = 1 denominator = 2 result = numerator / denominator print(f"1/{denominator} = {result}") 1/2 = 0.5 Method 2: Using range() Function ...
Read MoreCheck if the matrix is lower triangular using Python
In this article, we will learn a Python program to check if a matrix is lower triangular. A lower triangular matrix is a square matrix where all elements above the main diagonal are zero. What is a Lower Triangular Matrix? A square matrix is called lower triangular if all entries above the main diagonal are zero. Elements on or below the main diagonal can be any value. Example of Lower Triangular Matrix 1 0 0 0 2 3 0 0 1 3 7 0 0 4 8 4 In ...
Read MoreCalculating profit or loss using Python
In this article, we will learn how to create Python programs to calculate profit or loss by comparing cost price and selling price. We'll explore two different approaches to solve this business problem. Understanding Cost Price, Selling Price, Profit and Loss Before diving into the code, let's understand the basic concepts ? The cost price (CP) is the amount paid to purchase a product. The selling price (SP) is the amount received when selling that product. Profit occurs when selling price is greater than cost price ? Profit = Selling Price - Cost Price ...
Read MoreBreaking a Set into a list of sets using Python
In this article, we will learn how to break a Set into a list of sets in Python, where each element of the original set becomes a separate single-element set. A set is an unordered collection of unique elements. Sometimes we need to convert each element into its own set within a list structure. We'll explore three different approaches to accomplish this task ? Methods Used The following are the various methods used to accomplish this task ? Using For Loop and append(), add() functions Using Python map() & lambda functions Using List Comprehension ...
Read MoreAdding a data table to the figure using Python
In this article, we will learn how to add a data table to the figure using Python. Although matplotlib is primarily a plotting library, it also assists us with minor tasks when making a chart, such as having a nice data table alongside our attractive visuals. It is critical to understand why we are adding a table to a plot. The primary goal of plotting data visually is to clarify the otherwise incomprehensible data values. However, properly chosen, perhaps summarized, or highlighted values from the entire dataset might identify essential areas of the chart or highlight important values ...
Read MoreAdd a character to a specific position in a string using Python
In this article, we will learn how to add a character to a specific position in a string in Python. Python strings are immutable, so these methods create new strings rather than modifying the original. Methods to Add Characters to Strings The following are the various methods to accomplish this task − Using the '+' operator Using join() function Using format() function Method 1: Using the '+' Operator The '+' operator concatenates strings by combining them at specified positions. This is the most straightforward method for adding characters. Adding Character at the ...
Read MoreWhat is the best way to get stock data using Python?
In this article, we will learn the best way to get stock data using Python. The yfinance Python library will be used to retrieve current and historical stock market price data from Yahoo Finance API. This library is free to use and requires no API key. Installation of Yahoo Finance (yfinance) Yahoo Finance is one of the best platforms for acquiring stock market data. You can install yfinance using pip with the following command ? Syntax pip install yfinance The best part about the yfinance library is that it's completely free to ...
Read MoreHow to Read Machine Learning Papers?
Machine Learning and Deep Learning are rapidly evolving fields with new research published daily. Whether you're a beginner or experienced practitioner, learning to read research papers effectively is crucial for staying current with the latest developments and advancing your understanding. Reading machine learning papers requires a structured approach to maximize comprehension while minimizing time investment. This article outlines a systematic 5-step process for efficiently reading and understanding ML research papers. Step 1: Find Appropriate Papers Selecting the right papers is crucial for your learning journey. Reading papers that are too advanced or irrelevant to your goals can ...
Read More