Programming Articles

Page 158 of 2547

Check if the matrix is lower triangular using Python

Vikram Chiluka
Vikram Chiluka
Updated on 26-Mar-2026 540 Views

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 More

Calculating profit or loss using Python

Vikram Chiluka
Vikram Chiluka
Updated on 26-Mar-2026 7K+ Views

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 More

Breaking a Set into a list of sets using Python

Vikram Chiluka
Vikram Chiluka
Updated on 26-Mar-2026 628 Views

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 More

Adding a data table to the figure using Python

Vikram Chiluka
Vikram Chiluka
Updated on 26-Mar-2026 2K+ Views

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 More

Add a character to a specific position in a string using Python

Vikram Chiluka
Vikram Chiluka
Updated on 26-Mar-2026 68K+ Views

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 More

What is the best way to get stock data using Python?

Vikram Chiluka
Vikram Chiluka
Updated on 26-Mar-2026 13K+ Views

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 More

What are the uses of the "enumerate()" function on Python?

Vikram Chiluka
Vikram Chiluka
Updated on 26-Mar-2026 560 Views

The enumerate() function is a Python built-in that returns an enumerate object containing index-value pairs from any iterable. This function is essential when you need both the index and value while iterating through sequences. Syntax enumerate(iterable, start=0) Parameters iterable − Any sequence, collection, or iterator object (list, tuple, string, etc.) start − Optional starting index value. Default is 0 Basic Usage with Lists The enumerate() function returns an enumerate object that yields tuples containing (index, value) pairs ? # Basic enumerate usage fruits = ["apple", "banana", "orange", "grape"] ...

Read More

What are some projects that I can work on while learning Python?

Vikram Chiluka
Vikram Chiluka
Updated on 26-Mar-2026 309 Views

Learning Python becomes more effective when you build practical projects that reinforce programming concepts. This article explores beginner-friendly Python projects that help you practice essential skills while creating useful applications. Python's versatility makes it perfect for various domains including web development, data analysis, automation, and machine learning. The best way to master Python is through hands-on project development that combines learning with practical problem-solving. Number Guessing Game Build a simple game where players guess a secret number within a specific range. This project teaches fundamental programming concepts ? import random def number_guessing_game(): ...

Read More

How do I create a user interface through Python?

Vikram Chiluka
Vikram Chiluka
Updated on 26-Mar-2026 1K+ Views

In this article, we will learn how to create a user interface using Python. Python offers several powerful GUI frameworks that make building desktop applications straightforward and efficient. What is GUI? The term "Graphical User Interface" (or "GUI") refers to a set of visual elements that users can interact with in computer software to display information and control functionality. These elements include buttons, menus, text fields, and windows that respond to user input like clicks and keyboard entries. A well-designed GUI makes applications more accessible and user-friendly. Python provides excellent frameworks for building GUIs, ranging from simple ...

Read More

How can I make Python interesting for me?

Vikram Chiluka
Vikram Chiluka
Updated on 26-Mar-2026 410 Views

This article will teach us how to create some fascinating projects in Python to make your programming journey more engaging and practical. These projects combine real-world applications with technical skills to keep you motivated. Trading Bot While the economy, stock market, and cryptocurrencies experience volatility, many people are still profiting through automated trading strategies. Although you shouldn't invest real money in a trading bot without proper knowledge, it's an excellent learning project that teaches you about APIs, data analysis, and financial markets. Example: Simple Price Monitor import requests import time def get_bitcoin_price(): ...

Read More
Showing 1571–1580 of 25,466 articles
« Prev 1 156 157 158 159 160 2547 Next »
Advertisements