• Copy a dictionary in Python
    12 June

    7 ways to copy a dictionary in python

    💡 Outline **Shallow copy** You can use copy method of Dictionary to create shallow copy of dictionary in Python. [crayon-662b72c09155f015315511/] **Deep copy** You can use deepcopy() function of copy module to create deep copy of dictionary in Python. Dictionaries are a mutable structure in Python. We can alter the key-value pairs in a dictionary without […]

  • Escape quotes in Python
    11 June

    Escape quotes in Python

    💡 Outline You can use \ to escape quotes 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-662b72c091940906302201/] Escape sequences are frequently used in programming. They are used to convey to the compiler that the escape character has some other […]

  • 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-662b72c0939d3780985527/] 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 […]

  • Python hex to bytes
    31 May

    Convert Hex to bytes in Python

    1. Introduction to the Problem Statement In software development, converting hexadecimal (hex) strings to byte objects is a frequent requirement, especially when dealing with data formats and encoding. Hexadecimal, being a base-16 numeral system, offers a compact way to represent binary data, which is often needed in computational tasks. For instance, converting the hex string […]

  • 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-662b72c09609a999194284/] 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-662b72c096bda765083268/] 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 \ […]