• 15 December

    Python float to String

    In this tutorial, we will see how to convert float to String. You can simply use str method to convert float to String. Let’s understand with the help of simple example. [crayon-61a1217d995c3761845837/] Output: Converted f to String: 1.23444432 Let’s say you want to format String to only two decimal places. You can use below code […]

  • 15 December

    Python String to float

    In this tutorial, we will see how to convert String to float in python. You can simply use float() function to convert String to float. Let’s understand with the help of a simple example. [crayon-61a1217d99fac452169240/] Output: Type of f: 22.4543232 What happens if String cannot be converted to float If String cannot be converted to […]

  • 15 December

    Python dict setDefault

    In this tutorial, we will see about Python dict setDefault method. Python dictionary setDefault method is used to return the value if present in dictionary else inserts the key with value in dictionary if default value is provided. Syntax [crayon-61a1217d9a272432385281/] Return It returns the value if key exists in dictionary else it inserts key with […]

  • 15 December

    remove key from dictionary python

    In this tutorial, we will see how to remove key from the dictionary in Python. There are multiple ways to do it.Let’s explore a different way of deleting a key from the dictionary. Using pop method You can use pop method to remove key from dictionary.This is cleanest way to delete key from dictionary. [crayon-61a1217d9a556849655974/] […]

  • 09 December

    Python String to datetime

    In this tutorial, we will see how to convert String to datetime object. Let’s say, you got String as input and you want to convert it datetime object to extract various details from it. Using strptime Using parser Using strptime method You can simply use strptime to convert String to datetime. Let’s understand with the help of […]

  • 09 December

    Python datetime to String

    In this tutorial, we will see how to convert datetime to String object. Let’s say, you have datetime as input and you want to convert it string to display it. Using strftime Using format Using strptime method You can simply use strptime to convert datetime to String. Let’s understand with the help of example. [crayon-61a1217d9a9f5018831994/] Output: datetime […]

  • 08 December

    Python Convert list to set

    In this tutorial, we will see how to convert list to set. You can use python set() function to convert list to set.It is simplest way to convert list to set. As Set does not allow duplicates, when you convert list to set, all duplicates will be removed in the set. Let’s understand with the […]

  • 08 December

    How to create an empty list in python

    In this post, we will see how to create an empty list in python. There are two ways to create an empty list in Python. Using [ ] Using list() function. Let’s see this with the help of example. [crayon-61a1217d9af35052886257/] Output: List 1: [1, 2] List 2: [1, 2] Which is faster: [ ] or […]

  • 08 December

    convert set to list Python

    In this tutorial, we will see how to convert set to list in python. You can use python list() function to convert set to list.It is simplest way to convert set to list. Let’s understand with the help of example. [crayon-61a1217d9b1f4533743882/] Output: set of Fruits: {‘Apple’, ‘Banana’, ‘Orange’} listOfFruits: [‘Apple’, ‘Banana’, ‘Orange’] set of scales: […]