Pranav Indukuri has Published 49 Articles

How does the del operator work on a tuple in Python?

Pranav Indukuri

Pranav Indukuri

Updated on 02-Nov-2023 21:33:13

5K+ 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 ... Read More

How to convert a Python date string to a date object?

Pranav Indukuri

Pranav Indukuri

Updated on 02-Nov-2023 21:12:16

8K+ Views

In this article we convert a date string to a date object. We use the strptime() method to convert a date string to a date object. Strptime() The strptime() method takes the date as an input and converts it into a date object. Note that you cannot convert any string ... Read More

How to get file creation & modification date/times in Python?

Pranav Indukuri

Pranav Indukuri

Updated on 02-Nov-2023 21:07:23

10K+ Views

They are various ways to get the file creation and modification datetime in Python. We will use different methods from the OS and pathlib module to get the file creation and modification datetime in python. Using OS Module: File Creation Time On Windows Here we have used the OS module ... Read More

How to return the current CPU time in Python?

Pranav Indukuri

Pranav Indukuri

Updated on 02-Nov-2023 13:19:28

4K+ Views

In this article, we retrieve the current CPU time in Python. We use the time() method which is imported from the python time module. The time module in Python provides various methods and functions related to time. Here we use the time.time() method to get the current CPU time in ... Read More

How to get min, seconds and milliseconds from datetime.now() in Python?

Pranav Indukuri

Pranav Indukuri

Updated on 02-Nov-2023 02:38:08

13K+ Views

In this article, we will look at different ways to get minutes, seconds, and milliseconds from datetime now in Python. The datetime.now() method is used to get the current minutes, seconds, and milliseconds. This is defined under the datetime module. Syntax The syntax of now() method is as follows − ... Read More

How to convert a list into a tuple in Python?

Pranav Indukuri

Pranav Indukuri

Updated on 25-Oct-2023 14:30:50

22K+ Views

List and Tuple in Python are the class of data structure. The list is dynamic, whereas the tuple has static characteristics. We will understand list and tuple individually first and then understand how to convert a list into a tuple. List Lists are a popular and widely used data structures ... Read More

How to index and slice a tuple in Python?

Pranav Indukuri

Pranav Indukuri

Updated on 29-Aug-2023 03:45:22

25K+ 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 ... Read More

How to convert Python date to Unix timestamp?

Pranav Indukuri

Pranav Indukuri

Updated on 27-Aug-2023 03:42:55

27K+ Views

A UNIX timestamp is the total number of seconds that have been counted since the epoch. An epoch is the starting point of time and is platform-dependent. The epoch is January 1, 1970, 00:00:00 (UTC) on Windows and most Unix systems, and leap seconds are not included in the time ... Read More

How to convert date to datetime in Python?

Pranav Indukuri

Pranav Indukuri

Updated on 25-Aug-2023 01:48:31

36K+ Views

In this article, we will discuss how to convert a date to a datetime object in Python. We use the combine method from the datetime module to combine a date and time object to create a datetime object. Syntax The syntax of combine() method is as follows. datetime.combine(date, time) ... Read More

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

Pranav Indukuri

Pranav Indukuri

Updated on 25-Aug-2023 01:08:03

31K+ 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 ... Read More

Advertisements