• 07 June

    Number guessing game in Python

    A number guessing game is a common mini-project for basic programmers who have a grasp on random number generation and conditional statements with iteration. The number guessing game is based on a concept where player has to guess a number between given range. If player guesses the expected number then player wins else player loose […]

  • Sort list alphabetically in Python
    31 May

    Sort list alphabetically in Python

    💡 Outline You can use sort() method of list to sort list alphabetically in Python [crayon-60d25805a7375469784656/] In this tutorial, we will discuss different ways to sort a list namely using the sort() function, sorted() function, and implementing the quick sort algorithm. Use of the sort() function to sort list alphabetically in Python. The sort() method […]

  • Perfect number in Python
    31 May

    Perfect number program in Python

    According to number theory, a limb of pure mathematics that deals with integers, a Perfect Number can be defined as a positive integer whose value is equivalent to the sum of its proper positive divisors, excluding the number itself (alternatively known as aliquot sum). An example of a perfect number is the number 6, the […]

  • Sleep for milliseconds in python
    31 May

    How to sleep for milliseconds(ms) in Python

    💡 Outline You can use time.sleep() method to sleep for milliseconds in Python. If you want to delay python program by 500 ms, then you need to pass 0.5 as parameter to sleep method. [crayon-60d25805a7b26344969018/] Sometimes, the execution of a program needs to be suspended or paused for a given time. This is done so […]

  • 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-60d25805a7da4994753433/] 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-60d25805a80bd081310521/] 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 commas from String in Python

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