Pranav Indukuri

Pranav Indukuri

18 Articles Published

Articles by Pranav Indukuri

Page 2 of 2

How do we assign a value to several variables simultaneously in Python?

Pranav Indukuri
Pranav Indukuri
Updated on 23-Apr-2025 7K+ Views

Python is not a "statically typed" programming language. We do not need to define variables or their types before utilizing them. Once we initially assign a value to a variable, it is said to be created. Each variable is assigned with a memory location. The assignment operator (=) assigns the value provided to right to the variable name which is at its left. The syntax of the assignment operator is shown below - var_name = value Example of Assignment Operator The following is an example that shows the usage of the assignment operator - Name = 'Tutorialspoint' In ...

Read More

How do make a flat list out of list of lists in Python?

Pranav Indukuri
Pranav Indukuri
Updated on 23-Apr-2025 543 Views

A nested list is a list that has lists as elements. For example: [[1, 2, 3], [4, 5, 6], [7, 8, 9]] is a nested list as it has 3 lists ([1, 2, 3], [4, 5, 6], and [7, 8, 9]) as its elements. To flatten a list of lists (nested list), i.e., to convert a 2D list into a 1D list, there are different ways such as Nested for loop, List Comprehension, Built-in Functions, or by importing libraries in Python. In this article, we will discuss the above methods to flatten a list in Python. Using for loops For ...

Read More

How do you split a list into evenly sized chunks in Python?

Pranav Indukuri
Pranav Indukuri
Updated on 17-Apr-2025 3K+ Views

Sometimes it is necessary to divide a lengthy list into smaller and easy-to-read data. For example- if you wish to arrange a list of items in groups, it can be helpful to break it into small parts. This is useful for tasks like grouping data for analysis or showing items in a user interface. Python provides various simple methods to do this. In order to work with smaller data sets without losing any information, this article will show you how to split a list into uniformly sized chunks. What is List? List is one of the frequently used data ...

Read More

How to index and slice a tuple in Python?

Pranav Indukuri
Pranav Indukuri
Updated on 29-Aug-2023 37K+ Views

A tuple is an ordered and immutable collection of Python objects separated by commas. Like lists, tuples are sequences. Tuples differ from lists in that they can't be modified, whereas lists can, and they use parentheses instead of square brackets. tup=('tutorials', 'point', 2022, True) print(tup) If you execute the above snippet, produces the following output − ('tutorials', 'point', 2022, True) In this article, we will discuss how to index and slice tuples in python. Indexing Tuples In Python, every tuple with elements has a position or index. Each element of the tuple can be accessed or manipulated by ...

Read More

How do I calculate number of days between two dates using Python?

Pranav Indukuri
Pranav Indukuri
Updated on 25-Aug-2023 34K+ Views

In this article we will discuss how to find the number of days between two dates using Python. We use the datetime module to calculate the number of days between two dates using python. datetime module Python has a built-in datetime module that assists us in resolving a number of date-related issues. We just input the two dates with the date type and subtract them to discover the difference between the two dates, which gives us the number of days between the two dates. Syntax The syntax of the date() method in datetime module is as follows. datetime.date(year, month, day) ...

Read More

How does del operator work on list in Python?

Pranav Indukuri
Pranav Indukuri
Updated on 04-Apr-2023 913 Views

Lists are one of the four most commonly used data structures provided by Python. A list is a data structure in python that is mutable and has an ordered sequence of elements. Following is a list of integer values. lis= [1, 2, 3, 4, 5] print(lis) If you execute the above snippet, it produces the following output. [1, 2, 3, 4, 5] In this article, we will learn how a del operator works on a list in python. They are various scenarios where we use the del operator. The del operator The del keyword is mostly used in ...

Read More

How to convert pandas offset to Python date?

Pranav Indukuri
Pranav Indukuri
Updated on 07-Sep-2022 692 Views

In this article, we convert the pandas offset to date in python. When you subtract the pandas from a date object, you get a pandas Timestamp object. You can convert this object to a String format date or Date object(Standard Python date). Or you can use the timedelta object from the datetime library. Example 1 In the following example code, we remove the offset of 10 days using to_offset(“10D”) from the pandas pd.to_datetime(‘2018-01-04’). from pandas.tseries.frequencies import to_offset import pandas as pd dt = pd.to_datetime('2018-01-04') - to_offset("10D") print(type(dt)) print(dt) Output The output of the above code is as follows. ...

Read More

How do we compare Python Dates?

Pranav Indukuri
Pranav Indukuri
Updated on 05-Sep-2022 2K+ Views

In this article, we will understand how to compare python dates. They are different methods to identify which date is greater or lesser and these methods will be explored in detail. Using the timedelta() method and operator In this method, we use the datetime module and operator to compare two dates. To alter date and time, the datatime module provides timedelta() method. The timedelta() method takes the number of days as an input and returns the date. This method is used to perform arithmetic manipulations. Syntax The syntax of the timedelta() method from the datetime module in python ...

Read More
Showing 11–18 of 18 articles
« Prev 1 2 Next »
Advertisements