AmitDiwan has Published 10744 Articles

Python program to create a Circular Linked List of N nodes and count the number of nodes

AmitDiwan

AmitDiwan

Updated on 13-Mar-2021 05:51:06

190 Views

When it is required to create a circular linked list that has 'N' nodes, and get the count of the number of nodes, a 'Node' class needs to be created. To display the data elements in the circular list, another method can be defined, that would display the data. In ... Read More

Python Program to Shuffle Deck of Cards

AmitDiwan

AmitDiwan

Updated on 13-Mar-2021 05:50:44

2K+ Views

When it is required to shuffle a deck of cards using Python, the 'itertools' and the 'random' packages need to be used. Random library has a method named 'shuffle' that can be used to mix up and show the data.Below is a demonstration for the same −ExampleLive Demoimport itertools, random ... Read More

Python Circular Linked List Program

AmitDiwan

AmitDiwan

Updated on 13-Mar-2021 05:47:46

9K+ Views

When it is required to create a Python program that generates a linked list, a 'Node' class needs to be created. To display the data elements in the circular list, another method can be defined, that would display the data. In this class, there are two attributes, the data that ... Read More

Sort list of tuples by specific ordering in Python

AmitDiwan

AmitDiwan

Updated on 13-Mar-2021 05:45:54

351 Views

When it is required to sort the list of tuples in a specific order, the 'sorted' method can be used.The 'sorted' method is used to sort the elements of a list.A list can be used to store heterogeneous values (i.e data of any data type like integer, floating point, strings, ... Read More

Remove tuple from list of tuples if not containing any character in Python

AmitDiwan

AmitDiwan

Updated on 13-Mar-2021 05:45:21

494 Views

When it is required to remove a tuple from a list of tuples based on a given condition, i.e the tuple doesn't contain a specific character, the list comprehension can be used.A list can be used to store heterogeneous values (i.e data of any data type like integer, floating point, ... Read More

Remove tuples from list of tuples if greater than n in Python

AmitDiwan

AmitDiwan

Updated on 13-Mar-2021 05:43:43

429 Views

When it is required to remove tuples from a list of tuples if it is greater than a value 'n', the lambda function can be used.Anonymous function is a function which is defined without a name. In general, functions in Python are defined using 'def' keyword, but anonymous function is ... Read More

Update a list of tuples using another list in Python

AmitDiwan

AmitDiwan

Updated on 13-Mar-2021 05:43:19

316 Views

When it is required to update a list of tuple using another list, the 'defaultdict' can be used.Defaultdict is a container similar to dictionaries which is present in 'collections' module. It is a sub-class of the 'dict' class. It returns a dictionary-like object. The 'defaultdict' doesn't raise a KeyError ever. ... Read More

Selective value selection in list of tuples in Python

AmitDiwan

AmitDiwan

Updated on 13-Mar-2021 05:42:47

144 Views

When it is required to find the selective value in a list of tuples, the 'dict' method, the 'get' method and the list comprehension can be used.The list comprehension is a shorthand to iterate through the list and perform operations on it. A list can be used to store heterogeneous ... Read More

Split tuple into groups of n in Python

AmitDiwan

AmitDiwan

Updated on 13-Mar-2021 05:39:36

566 Views

When it is required to split the tuple into 'n' groups, the list comprehension can be used. A tuple is an immutable data type. It means, values once defined can't be changed by accessing their index elements. If we try to change the elements, it results in an error. They ... Read More

Modifying tuple contents with list in Python

AmitDiwan

AmitDiwan

Updated on 13-Mar-2021 05:39:00

230 Views

When it is required to modify the list of tuple, the 'zip' method and the list comprehension can be used.The zip method takes iterables, aggregates them into a tuple, and returns it as the result.The list comprehension is a shorthand to iterate through the list and perform operations on it.A ... Read More

Advertisements