Found 10476 Articles for Python

Binary list to integer in Python

Pradeep Elance
Updated on 19-Dec-2019 11:14:51

2K+ Views

We can convert a list of 0s and 1s representing a binary number to a decimal number in python using various approaches. In the below examples we use the int() method as well as bitwise left shift operator.Using int()The int() method takes in two arguments and changes the base of the input as per the below syntax.int(x, base=10) Return an integer object constructed from a number or string x.In the below example we use the int() method to take each element of the list as a string and join them to form a final string which gets converted to integer ... Read More

Difference between Python and PHP.

Mahesh Parahar
Updated on 28-Nov-2019 10:48:34

493 Views

PythonPython is a high level programming language with inbuilt big library and is used to develop standalone programs. It was developed by Guido Van Rossum and its first version was released in the year 1990.PHPPHP stands for Hypertext Preprocessor, it is server side scripting language. It was developed in 1995. It is used to create dynamic web based pages.Following are the important differences between Python and PHP.Sr. No.KeyPythonPHP1Learning CurvePython requires good effort if one learns from scratch. It is similar to C++ and Java.PHP is easy to learn if user knows html and javascript.2FrameworksPopular Python frameworks are Flask, DJango.Popular PHP ... Read More

Difference between List and Tuples in Python

Shriansh Kumar
Updated on 30-Jul-2024 16:43:11

14K+ Views

List and Tuples are built-in data types of Python programming language. They serve as a container to hold multiple values of same type as well as different data types. We can find several differences in both of these containers. Read this article to learn more about lists and tuples in Python and how they are different from each other. List in Python List is a container that contains different types of objects. In it, the elements are separated by commas and stored within square brackets. Each element of a list has a unique position index, starting from 0. ... Read More

Difference Between Go and Python Programming Language

Kiran Kumar Panigrahi
Updated on 28-Jul-2022 12:34:26

423 Views

Python debuted in 1991. Google released Golang in 2012. Google's programmers built Golang to expedite development and improve other languages. Golang has stricter grammar and layout than Python.Golang allows multitasking, use of channels, goroutines, etc. Golang can be used in networking, cloud, and server-side projects. Golang can automate DevOps and site reliability. Microcontrollers, games, and robots are programmed in Golang. Golang powers Kubernetes, Prometheus, and Docker.Python is an object oriented programming language designed by Guido van Rossum in 1991 and is maintained by Python Software Foundation. Python was developed to keep language readability easy and to quickly integrate with other ... Read More

Find the version of the Pandas and its dependencies in Python

Arnab Chakraborty
Updated on 04-Nov-2019 10:09:29

239 Views

Pandas is the important package for data analysis in Python. There are different versions available for Pandas. Due to some version mismatch, it may create some problems. So we need to find the version numbers of the Pandas. We can see them easily using the following code.We can use the command like below, to get the version −pandas.__version__Example>>> import pandas as pd >>> print(pd.__version__) 0.25.2 >>>We can also get the version of the dependencies using the function like below −pandas.show_versions() >>> pd.show_versions() INSTALLED VERSIONS ------------------ commit : None python : 3.7.1.final.0 python-bits : 64 OS : Windows OS-release : 7 ... Read More

Anagram Substring Search using Python

Yaswanth Varma
Updated on 24-Jul-2025 15:54:54

330 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 includes two strings (text, pattern); we need to search the given text for any substring that contains the same characters as the pattern, in any order. Scenario Following is an example scenario: Input: str1="cbaebabacd", str2="abc" Output: [0, 6] Explanation: In this case, The substring "cba" at index 0 is an anagram of "abc". The substring "bac" at index 6 is an ... Read More

Adding a new column to existing DataFrame in Pandas in Python

Hafeezul Kareem
Updated on 26-Aug-2023 08:39:59

35K+ Views

In this tutorial, we are going to learn how to add a new column to the existing DataFrame in pandas. We can have different methods to add a new column. Let's all of them.Using ListWe can add a new column using the list. Follow the steps to add a new column.Algorithm1. Create DataFrame using a dictionary. 2. Create a list containing new column data. Make sure that the length of the list matches the length of the data which is already present in the data frame. 3. Add the list to the DataFrame like dictionary element.Let's see one example.Example# importing ... Read More

Anagram checking in Python program using collections.Counter()

Yaswanth Varma
Updated on 14-Jul-2025 15:08:00

279 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. For example, Scenario Input: str1= "listen", str2= "silent" Output: True Two strings are said ... Read More

Analysing Mobile Data Speeds from TRAI with Pandas in Python

Yaswanth Varma
Updated on 14-Jul-2025 15:23:33

205 Views

The Telecom Regulatory Authority of India (TRAI) publishes the data regarding mobile internet speeds for various telecom operations across India. It 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 downloaded the CSV file named demo.csv with the following structure to use in the examples. demo.csv file ... Read More

Apply function to every row in a Pandas DataFrame in Python

Hafeezul Kareem
Updated on 01-Nov-2019 09:50:20

1K+ Views

In this tutorial, we are going to learn about the most common methods of a list i.e.., append() and extend(). Let's see them one by one.apply()It is used to apply a function to every row of a DataFrame. For example, if we want to multiply all the numbers from each and add it as a new column, then apply() method is beneficial. Let's see different ways to achieve it.Example# importing the pandas package import pandas as pd # function to multiply def multiply(x, y):    return x * y # creating a dictionary for DataFrame data = {    'Maths': ... Read More

Advertisements