Vikram Chiluka has Published 288 Articles

How to convert timestamp string to datetime object in Python?

Vikram Chiluka

Vikram Chiluka

Updated on 27-Aug-2023 12:36:51

22K+ Views

In this article, we will show you how to convert a timestamp string to DateTime object in Python. Below are the various methods to accomplish this task − Using datetime.fromtimestamp() function Using datetime.fromtimestamp() & strftime Using datetime.strptime() Convert timestamp to a date time object with format codes with mixed ... Read More

How to insert an object in a list at a given position in Python?

Vikram Chiluka

Vikram Chiluka

Updated on 27-Aug-2023 03:34:37

31K+ Views

In Python, a list is an ordered sequence that can hold several object types such as integer, character, or float. In other programming languages, a list is equivalent to an array. In this article, we will show you how to insert an item/object in a list at a given position ... Read More

How to do date validation in Python?

Vikram Chiluka

Vikram Chiluka

Updated on 27-Aug-2023 03:29:17

29K+ Views

In this article, we will show you how to do date validation in Python. Now we see 2 methods to accomplish this task− Using datetime.strptime() function Using dateutil.parser.parse() function Method 1: Using datetime.strptime() function Algorithm (Steps) Following are the Algorithm/steps to be followed to perform the desired task ... Read More

How I can convert a Python Tuple into Dictionary?

Vikram Chiluka

Vikram Chiluka

Updated on 26-Aug-2023 08:37:40

32K+ Views

The Python tuple elements are enclosed inside the parenthesis, while dictionary elements are present in the form of a key-value pair and are enclosed between curly brackets. In this article, we will show you how to convert a Python tuple into a dictionary. The following are the methods to convert ... Read More

How to generate non-repeating random numbers in Python?

Vikram Chiluka

Vikram Chiluka

Updated on 26-Aug-2023 03:38:07

37K+ Views

In this article, we will show you how to generate non-repeating random numbers in Python. Below are the methods to accomplish this task: Using randint() & append() functions Using random.sample() method of given list Using random.sample() method of a range of numbers Using random.choices() method Using randint() ... Read More

Difference between for loop and while loop in Python

Vikram Chiluka

Vikram Chiluka

Updated on 26-Aug-2023 03:25:00

39K+ Views

In this post, we will understand the difference between the 'for' and the 'while' loop. For Loop A for loop is a control flow statement that executes code for a predefined number of iterations. The keyword used in this control flow statement is "for". When the number of iterations is ... Read More

How to remove an object from a list in Python?

Vikram Chiluka

Vikram Chiluka

Updated on 26-Aug-2023 03:15:52

41K+ Views

To remove items (elements) from a list in Python, use the list functions clear(), pop(), and remove(). You can also delete items with the del statement by specifying a position or range with an index or slice. In this article, we will show you how to remove an object/element from ... Read More

How to convert date and time with different timezones in Python?

Vikram Chiluka

Vikram Chiluka

Updated on 25-Aug-2023 01:57:04

38K+ Views

In this article, we will show you how to convert date and time with different timezones in Python. Using astimezone() function Using datetime.now() function The easiest way in Python date and time to handle timezones is to use the pytz module. This library allows accurate and cross−platform timezone ... Read More

How to get a list of all the keys from a Python dictionary?

Vikram Chiluka

Vikram Chiluka

Updated on 25-Aug-2023 01:41:27

39K+ Views

In this article, we will show you how to get a list of all the keys from a Python dictionary using various methods. We can get the list of all the keys from a Python dictionary using the following methods − Using dict.keys() method Using list() & dict.keys() function ... Read More

Add a character to a specific position in a string using Python

Vikram Chiluka

Vikram Chiluka

Updated on 25-Aug-2023 00:51:31

48K+ Views

In this article, we will learn how to add a character to a specific position in a string in Python. Methods Used The following are the various methods to accomplish this task − Using the '+' operator Using join() function Using format() function Method 1: Using the '+' ... Read More

Advertisements