AmitDiwan has Published 10744 Articles

Flatten Tuples List to String in Python

AmitDiwan

AmitDiwan

Updated on 12-Mar-2021 05:41:26

373 Views

When it is required to flatten a list of tuples into a string format, the 'str' method and the 'strip' method can be used.A list can be used to store heterogeneous values (i.e data of any data type like integer, floating point, strings, and so on).A list of tuples basically ... Read More

How to Concatenate tuples to nested tuples in Python

AmitDiwan

AmitDiwan

Updated on 12-Mar-2021 05:40:44

1K+ Views

When it is required to concatenate tuples to nested tuples, the '+' operator 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 are ... Read More

Convert tuple to float value in Python

AmitDiwan

AmitDiwan

Updated on 12-Mar-2021 05:40:22

4K+ Views

When it is required to convert a tuple to a float value, the 'join' method, 'float' method, 'str' method and generator expression can be used.Generator is a simple way of creating iterators. It automatically implements a class with '__iter__()' and '__next__()' methods and keeps track of the internal states, as ... Read More

Find Dissimilar Elements in Tuples in Python

AmitDiwan

AmitDiwan

Updated on 12-Mar-2021 05:37:53

169 Views

When it is required to find dissimilar elements in tuples, the 'set' operator and the '^' operator can be used.Python comes with a datatype known as 'set'. This 'set' contains elements that are unique only.The set is useful in performing operations such as intersection, difference, union and symmetric difference.The '^' ... Read More

Convert tuple to adjacent pair dictionary in Python

AmitDiwan

AmitDiwan

Updated on 12-Mar-2021 05:37:32

242 Views

When it is required to convert a tuple to an adjacency pair dictionary, the 'dict' method, the dictionary comprehension, and slicing can be used.A dictionary stores values in the form of a (key, value) pair. The dictionary comprehension is a shorthand to iterate through the dictionary and perform operations on ... Read More

Count the elements till first tuple in Python

AmitDiwan

AmitDiwan

Updated on 12-Mar-2021 05:35:03

169 Views

When it is required to count the elements up to the first tuple, a simple loop, the 'isinstance' method, and the 'enumerate' method can be used.Below is a demonstration of the same −ExampleLive Demomy_tuple_1 = (7, 8, 11, 0 ,(3, 4, 3), (2, 22)) print ("The tuple is : ... Read More

Check for None Tuple in Python

AmitDiwan

AmitDiwan

Updated on 12-Mar-2021 05:34:34

2K+ Views

When it is required to check for 'None' value in a tuple, the 'all' method and the generator expression can be used.The 'all' method checks to see if all the values inside an iterable are True values. If yes, it returns True, else returns False.Below is a demonstration of the ... Read More

How to get Subtraction of tuples in Python

AmitDiwan

AmitDiwan

Updated on 12-Mar-2021 05:33:54

3K+ Views

When it is required to subtract the tuples, the 'map' method and lambda function can be used.The map function applies a given function/operation to every item in an iterable (such as list, tuple). It returns a list as the result.Anonymous function is a function which is defined without a name. ... Read More

Python Program to Create a Class and Compute the Area and the Perimeter of the Circle

AmitDiwan

AmitDiwan

Updated on 11-Mar-2021 12:57:17

4K+ Views

When it is required to find the area and perimeter of a circle using classes, object oriented method is used. Here, a class is defined, and attributes are defined. Functions are defined within the class that perform certain operations. An instance of the class is created, and the functions are ... Read More

Python Program to Append, Delete and Display Elements of a List Using Classes

AmitDiwan

AmitDiwan

Updated on 11-Mar-2021 12:55:26

2K+ Views

When it is required to append, delete, and display the elements of a list using classes, object oriented method is used. Here, a class is defined, and attributes are defined. Functions are defined within the class that perform certain operations. An instance of the class is created, and the functions ... Read More

Advertisements