• Python hex to bytes
    31 May

    Convert Hex to bytes in Python

    💡 Outline You can use codecs’s decode() function to convert Hex to bytes in python. This method works for Python 2.x and Python 3.x Here is an example: [crayon-6103d207c8dfe460057904/] In the world of programming, there are many conversions of data types that programmers have to perform that best suit their problem statements. One of these […]

  • Find common elements in two lists Python
    25 May

    Find common elements in two lists in python

    💡 Outline You can first convert first list into set using set() and call intersection() by passing second list as parameter to find common element in two lists in Python. [crayon-6103d207c94af167736607/] In this tutorial, we will see different methods to find common elements in two lists in python. Using the intersection() Function This is the […]

  • Remove commas from String in Python
    23 May

    Remove comma from String in Python

    💡 Outline You can remove comma from string in python by using string’sreplace() method. Syntax: [crayon-6103d207c96b4587980624/] In this tutorial, we will take a sample string with a couple of commas in it and we will see some methods to remove comma from string in Python. Using replace() function to remove comma from string in Python […]

  • Get filename from path in Python
    21 May

    Get filename from Path in Python

    There are different ways to define the path of the file. In Windows, the path separator for a file can be either a backslash or a forward slash. The ntpath module of Python will work on all platforms for all paths. The forwardslash / is used for UNIX and MacOS operating system and backslash \ […]

  • Convert unix timestamp to datetime in Python
    21 May

    Convert Unix timestamp to DateTime in python

    A UNIX timestamp is defined as the several numbers of seconds between a particular date and the Epoch i.e January 1, 1970 at UTC. In this tutorial, we will see some methods by which we can convert a UNIX timestamp to DateTime in Python. Using fromtimestamp() Function DateTime module in python is used to deal […]

  • Add character to String in Python
    21 May

    Add character to String in Python

    Strings are considered as a sequence of characters in programming. In Python, string objects are considered immutable. What this means is that string objects cannot be changed once created, and a new string is created with a different block of memory when we edit a string. In this article, we will discuss how to add […]

  • Python round to 2 decimal places
    21 May

    How to round to 2 decimals in Python

    In Python, we deal with integers, floating values, and even imaginary numbers. Float numbers are used to represent the real numbers with integers and decimal parts. Python represents such numbers with 64-bit precision giving it a range of almost 1.8 x 10^308. In this article, we will discuss how to round float values to 2 […]

  • Random number between 1 and 10 in Python
    21 May

    Generate random number between 1 and 10 in Python

    Random numbers have very important applications in the world of programming. They can be used to create simulations, test cases for statistical or cryptoanalysis, for creating situations where we require a random or unpredictable result, and more. In Python, we can generate a wide range of ragndom numbers using different modules and functions. In this […]

  • Last day of month in Python
    20 May

    Get last day of month in Python

    In this article, we will discuss how to find the last day of the month in Python using different modules. Using the calendar.monthrange() function The monthrange() function is used to return a tuple containing the first weekday of the month and the total number of days in the month. We have to pass the year […]