Programming Articles

Page 614 of 2547

Formatted text in Linux Terminal using Python

karthikeya Boyini
karthikeya Boyini
Updated on 25-Mar-2026 411 Views

In this section, we will see how to print formatted texts in Linux terminal. By formatting, we can change the text color, style, and some special features using ANSI escape sequences. Linux terminal supports ANSI escape sequences to control the formatting, color and other features. We embed these special bytes with the text, and when the terminal interprets them, the formatting becomes effective. ANSI Escape Sequence Syntax The general syntax of ANSI escape sequence is ? \x1b[A;B;C Where: A is the Text Formatting Style B is the Text Color or Foreground ...

Read More

Generate a graph using Dictionary in Python

karthikeya Boyini
karthikeya Boyini
Updated on 25-Mar-2026 2K+ Views

Graphs can be implemented using Dictionary in Python where each key represents a vertex and its value contains a list of connected vertices. This creates an adjacency list representation of a graph G(V, E). We'll use Python's defaultdict from the collections module, which provides additional features over regular dictionaries by automatically creating missing keys with default values. Graph Representation Consider this undirected graph with 6 vertices (A, B, C, D, E, F) and 8 edges ? A B ...

Read More

Tracking bird migration using Python-3

karthikeya Boyini
karthikeya Boyini
Updated on 25-Mar-2026 569 Views

Bird migration tracking using GPS technology provides valuable insights into animal behavior patterns. Researchers use GPS modules to monitor how birds travel to different locations throughout the year, collecting data on their routes, timing, and movement patterns. In this tutorial, we'll analyze a bird tracking dataset containing GPS coordinates, timestamps, and movement data. The dataset is in CSV format with fields including bird ID, date_time, latitude, longitude, and speed. Required Libraries We need several Python libraries for data analysis and visualization. Install them using conda − conda install -c conda-forge matplotlib conda install -c anaconda ...

Read More

Simple Chat Room using Python

Samual Sam
Samual Sam
Updated on 25-Mar-2026 3K+ Views

In this article we will see how to make a server and client chat room system using Socket Programming with Python. The sockets are the endpoints of any communication channel. These are used to connect the server and client. Sockets are Bi-Directional. In this tutorial, we will setup sockets for each end and create a chatroom system among different clients through the server. The server side has some ports to connect with client sockets. When a client tries to connect with the same port, then the connection will be established for the chat room. There are basically two ...

Read More

How to flatten a shallow list in Python?

Gireesha Devara
Gireesha Devara
Updated on 25-Mar-2026 2K+ Views

Flattening a shallow list means converting a nested list into a simple, single-dimensional list. In other words, converting a multidimensional list into a one-dimensional list. Flattening can be performed using different techniques like nested for loops, list comprehensions, list concatenation, and using built-in functions. In this article, we will discuss a few techniques to flatten a shallow Python list. Flattening a shallow list using a nested for loop By using a nested for loop and a list.append() method, we can flatten the shallow list. Let’s have a look and see how this can be done in a program. Example This simple example ...

Read More

Send mail with attachment from your Gmail account using Python

Samual Sam
Samual Sam
Updated on 25-Mar-2026 10K+ Views

In this article, we will see how to send email with attachments using Python. To send mail, we do not need any external library. There is a module called smtplib, which comes with Python. It uses SMTP (Simple Mail Transfer Protocol) to send the mail and creates SMTP client session objects for mailing. SMTP needs valid source and destination email IDs, and port numbers. The port number varies for different sites. For Gmail, the port is 587. Required Modules We need to import the following modules ? import smtplib from email.mime.multipart import MIMEMultipart from email.mime.text ...

Read More

Fraction module in Python

SaiKrishna Tavva
SaiKrishna Tavva
Updated on 25-Mar-2026 7K+ Views

Python's fractions module provides support for rational number arithmetic. Using this module, we can create fractions from integers, floats, decimals, strings, and other numeric values. The Fraction constructor accepts a numerator and denominator as parameters. The default numerator is 0 and the default denominator is 1. It raises ZeroDivisionError when the denominator is 0. Creating Fraction Instances Let's see how to create fractions using numerator and denominator values ? from fractions import Fraction print(Fraction(45, 54)) print(Fraction(12, 47)) print(Fraction(0, 15)) print(Fraction(10)) # denominator defaults to 1 5/6 12/47 0 10 ...

Read More

How to get synonyms/antonyms from NLTK WordNet in Python

karthikeya Boyini
karthikeya Boyini
Updated on 25-Mar-2026 3K+ Views

The WordNet is a part of Python's Natural Language Toolkit. It is a large word database of English Nouns, Adjectives, Adverbs and Verbs. These are grouped into some set of cognitive synonyms, which are called synsets. To use the Wordnet, at first we have to install the NLTK module, then download the WordNet package. $ sudo pip3 install nltk $ python3 >>> import nltk >>> nltk.download('wordnet') In the wordnet, there are some groups of words, whose meaning are same. Let's explore how to extract synonyms, antonyms, and word details using NLTK WordNet. Getting Word ...

Read More

Quickly convert Decimal to other bases in Python

AmitDiwan
AmitDiwan
Updated on 25-Mar-2026 2K+ Views

To quickly convert decimal numbers to other bases, Python provides built-in functions that make the process simple and efficient − Decimal to Binary − bin() Decimal to Octal − oct() Decimal to Hexadecimal − hex() The decimal number system has base 10 and uses digits 0-9. Binary (base 2) uses only 0 and 1. Octal (base 8) uses digits 0-7. Hexadecimal (base 16) uses digits 0-9 and letters A-F (where A=10, B=11, C=12, D=13, E=14, F=15). Convert Decimal to Binary The bin() function converts a decimal number to its binary representation ? ...

Read More

Implementing Photomosaics in Python

Samual Sam
Samual Sam
Updated on 25-Mar-2026 767 Views

A photomosaic is a technique where an image is divided into a grid of squares, with each square replaced by other images or colored blocks. When viewed from a distance, the original image is visible, but up close, you see individual colored tiles creating the mosaic effect. In Python, we can create photomosaics using the photomosaic module, which provides an easy way to generate stunning mosaic effects from any image. Installation Install the photomosaic module using pip ? pip install photomosaic This will also install the required scikit-learn dependency. Key Features ...

Read More
Showing 6131–6140 of 25,466 articles
« Prev 1 612 613 614 615 616 2547 Next »
Advertisements