AmitDiwan has Published 10744 Articles

Python Program to Find the Area of a Rectangle Using Classes

AmitDiwan

AmitDiwan

Updated on 11-Mar-2021 12:52:41

4K+ Views

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

Python | Sum of number digits in List

AmitDiwan

AmitDiwan

Updated on 11-Mar-2021 12:49:33

3K+ Views

When it is required to sum the number of digits in a list, a simple loop and the ‘str’ 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).The ‘str’ method converts the given ... Read More

Python | Remove empty tuples from a list

AmitDiwan

AmitDiwan

Updated on 11-Mar-2021 12:47:59

1K+ Views

When it is required to remove empty tuples from a list of tuples, a simple loop 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 tuple basically contains tuples enclosed in a ... Read More

Python | Sort the values of first list using second list

AmitDiwan

AmitDiwan

Updated on 11-Mar-2021 12:46:46

544 Views

When it is required to sort the values of the first list with the help of the second list, the ‘sorted’ method and the ‘zip’ methods are 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).The ... Read More

Python Program to Edit objects inside tuple

AmitDiwan

AmitDiwan

Updated on 11-Mar-2021 12:44:58

136 Views

When it is required to edit the objects inside a tuple, simple indexing 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).Below is a demonstration for the same −Example Live Demomy_tuple = (45, 67, [35, ... Read More

Python Program that Displays which Letters are Present in Both the Strings

AmitDiwan

AmitDiwan

Updated on 11-Mar-2021 12:44:01

781 Views

When it is required to display the letters common to two strings, the ‘set’ method 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.Below is a demonstration ... Read More

Python Program to Find Longest Common Substring using Dynamic Programming with Bottom-Up Approach

AmitDiwan

AmitDiwan

Updated on 11-Mar-2021 12:41:24

304 Views

When it is required to find longest common substring using dynamic programming with bottom-up approach, a method can be defined, that computes the solution to smaller problems. These smaller problem results don’t need to be computed again and again. Instead, they can just be accessed when required. This would lead ... Read More

Python - Assign a specific value to Non Max-Min elements in Tuple

AmitDiwan

AmitDiwan

Updated on 11-Mar-2021 12:39:14

118 Views

When it is required to assign a specific value to the non max-min elements in a tuple, the ‘max’ method, the ‘min’ method, the ‘tuple’ method and a loop can be used.The ‘max’ method returns the maximum value among all of the elements in an iterable. The ‘min’ method returns ... Read More

Python program to sort a list of tuples by second Item

AmitDiwan

AmitDiwan

Updated on 11-Mar-2021 12:36:43

633 Views

When it is required to sort a list of tuples based on the second item, the lambda function and ‘sorted’ 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 tuple ... Read More

Python Program to Print an Identity Matrix

AmitDiwan

AmitDiwan

Updated on 11-Mar-2021 12:35:14

835 Views

When it is required to print an identity matrix, nested loops can be used.Below is a demonstration for the same −Example Live Demon = 4 print("The value of n has been initialized to " +str(n)) for i in range(0, n):    for j in range(0, n):       if(i==j):   ... Read More

Advertisements