Python Articles

Page 693 of 855

To print all elements in sorted order from row and column wise sorted matrix in Python

Niharikaa Aitam
Niharikaa Aitam
Updated on 25-Mar-2026 388 Views

In Python, we may work with matrices that are sorted in a particular order. A common case is a matrix where each row and each column is sorted in increasing order, but the entire matrix is not necessarily sorted. In such cases, we need to extract all elements and print them in a fully sorted order. Understanding Row and Column-wise Sorted Matrix A row and column-wise sorted matrix means each row is sorted from left to right, and each column is sorted from top to bottom. For example, consider the following matrix − matrix ...

Read More

Python - Check if all elements in a List are same

Niharikaa Aitam
Niharikaa Aitam
Updated on 25-Mar-2026 29K+ Views

In Python, a list is a collection of ordered and mutable elements enclosed in square brackets []. Each element in a list has a unique position index, starting from 0. It can accept duplicate elements. In some cases, we may need to check if all the elements in a list are identical or not to detect a special condition in algorithms. Let's go through the different methods to check if all elements in a list are the same or not. Using set() Function The Python set() function (built-in) creates an unordered collection of unique elements. To check ...

Read More

Generate two output strings depending upon occurrence of character in input string in Python

Niharikaa Aitam
Niharikaa Aitam
Updated on 25-Mar-2026 206 Views

In Python, a string is a sequence of characters enclosed within single quotes '' or double quotes "". When processing strings, we often need to analyze character occurrence patterns to generate different outputs based on frequency. To generate two output strings based on character occurrence in Python, we follow these steps: Count the frequency of each character in the input string using a dictionary or collections.Counter Separate characters into two categories: ...

Read More

Difference between List and Tuples in Python

Shriansh Kumar
Shriansh Kumar
Updated on 25-Mar-2026 15K+ Views

Lists and tuples are built-in data types in Python programming language. They serve as containers to hold multiple values of the same type as well as different data types. Understanding the differences between lists and tuples is crucial for choosing the right data structure for your Python programs. This article explores their key characteristics and differences. List in Python A list is a mutable container that holds different types of objects. Elements are separated by commas and enclosed within square brackets. Each element has a unique position index starting from 0. Creating and Modifying Lists ...

Read More

Difference Between Go and Python Programming Language

Kiran Kumar Panigrahi
Kiran Kumar Panigrahi
Updated on 25-Mar-2026 499 Views

Python debuted in 1991, while Google released Golang in 2012. Google's programmers built Golang to expedite development and improve upon other languages. Golang has stricter grammar and syntax than Python, making it a statically typed compiled language. Golang allows multitasking through channels and goroutines, making it ideal for networking, cloud computing, and server-side projects. It can automate DevOps tasks and site reliability engineering. Golang powers major projects like Kubernetes, Prometheus, and Docker. Python is an object-oriented programming language designed by Guido van Rossum in 1991 and maintained by the Python Software Foundation. Python was developed to keep language ...

Read More

Find the version of the Pandas and its dependencies in Python

Arnab Chakraborty
Arnab Chakraborty
Updated on 25-Mar-2026 284 Views

Pandas is a crucial package for data analysis in Python. Different versions may have compatibility issues, so it's important to check your Pandas version and its dependencies. Python provides several methods to retrieve this information. Finding Pandas Version The simplest way to check the Pandas version is using the __version__ attribute ? import pandas as pd print(pd.__version__) 2.1.4 Alternative Methods to Check Version Using pkg_resources import pkg_resources version = pkg_resources.get_distribution("pandas").version print(version) 2.1.4 Using importlib.metadata from importlib.metadata import version print(version('pandas')) ...

Read More

Anagram Substring Search using Python

Yaswanth Varma
Yaswanth Varma
Updated on 25-Mar-2026 465 Views

An anagram is a rearrangement of the characters of a word or a phrase to generate a new word, using all the original characters exactly once. For example, thing and night are anagrams of each other. An anagram substring search involves finding all substrings in a text that are anagrams of a given pattern. This means we need to find substrings that contain the same characters as the pattern, regardless of their order. Problem Statement Given two strings text and pattern, find all starting indices of substrings in the text that are anagrams of the pattern. ...

Read More

Adding a new column to existing DataFrame in Pandas in Python

Hafeezul Kareem
Hafeezul Kareem
Updated on 25-Mar-2026 35K+ Views

In this tutorial, we are going to learn how to add a new column to an existing DataFrame in pandas. There are several methods to accomplish this task, each with its own advantages depending on your specific needs. Using Direct Assignment The simplest way to add a new column is by using direct assignment with a list. This method assigns the new column data to the DataFrame like a dictionary element − Example # importing pandas import pandas as pd # creating a DataFrame data = { 'Name': ['Hafeez', 'Aslan', ...

Read More

Anagram checking in Python program using collections.Counter()

Yaswanth Varma
Yaswanth Varma
Updated on 25-Mar-2026 412 Views

An anagram is a word or phrase formed by rearranging the letters of a different word or phrase, using all the original letters exactly once. For example, thing and night are anagrams of each other. In this article, we are going to learn how to check an anagram in a Python program using collections.Counter() method. This method counts the number of occurrences of each element in a collection (like characters in a string), helping us to compare two words for identical character counts ? Understanding the Problem Input: str1= "listen", str2= "silent" Output: True ...

Read More

Analysing Mobile Data Speeds from TRAI with Pandas in Python

Yaswanth Varma
Yaswanth Varma
Updated on 25-Mar-2026 268 Views

The Telecom Regulatory Authority of India (TRAI) publishes data regarding mobile internet speeds for various telecom operators across India. This data is useful for users and telecom companies to evaluate and compare the performance of different service providers. In this article, we are going to use pandas in Python to analyze the TRAI mobile data speed reports. Let's assume we have a CSV file named demo.csv with the following structure to use in the examples. Sample Data Structure ...

Read More
Showing 6921–6930 of 8,549 articles
« Prev 1 691 692 693 694 695 855 Next »
Advertisements