Python Articles

Page 67 of 855

Python program to find the maximum and minimum value node from a doubly linked list

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 499 Views

When it is required to find the maximum and minimum values from a doubly linked list, a ‘Node’ class needs to be created. In this class, there are three attributes, the data that is present in the node, the access to the next node of the linked list, and the access to the previous node of the linked list.Below is a demonstration for the same −Exampleclass Node:    def __init__(self, my_data):       self.prev = None       self.data = my_data       self.next = None class double_list:    def __init__(self):       self.head = None ...

Read More

Python program to insert a new node at the beginning of the Doubly Linked list

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 458 Views

When it is required to insert a new node at the beginning of a doubly linked list, a ‘Node’ class needs to be created. In this class, there are three attributes, the data that is present in the node, the access to the next node of the linked list, and the access to the previous node of the linked list.Below is a demonstration for the same −Exampleclass Node:    def __init__(self, my_data):       self.prev = None       self.data = my_data       self.next = None class double_list:    def __init__(self):       self.head = ...

Read More

Python Program to Edit objects inside tuple

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 189 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 −Examplemy_tuple = (45, 67, [35, 66, 74], 89, 100) print("The tuple is : ") print(my_tuple) my_tuple[2][1] = 63 print("The tuple after changes is : ") print(my_tuple)OutputThe tuple is : (45, 67, [35, 66, 74], 89, 100) The tuple after changes is : (45, 67, [35, 63, 74], 89, 100)ExplanationA tuple of list is defined, and is ...

Read More

Python program to insert a new node at the end of the Doubly Linked List

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 591 Views

When it is required to insert a new node at the end of a doubly linked list, a ‘Node’ class needs to be created. In this class, there are three attributes, the data that is present in the node, the access to the next node of the linked list, and the access to the previous node of the linked list.Below is a demonstration for the same −Exampleclass Node:    def __init__(self, my_data):       self.prev = None       self.data = my_data       self.next = None class double_list:    def __init__(self):       self.head = ...

Read More

Python | Remove empty tuples from a list

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 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 list.Below is a demonstration for the same −Exampledef remove_empty(my_tuple):    my_tuple = [t for t in my_tuple if t]    return my_tuple my_tuple = [(), (), (''), (" " , " "), (45, 67, 35, 66, 74, 89, 100) , 'jane'] print("The tuple is : ") print(my_tuple) print("The method to ...

Read More

Python program to insert a new node at the middle of the Doubly Linked List

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 464 Views

When it is required to insert a new node in the middle of a doubly linked list, a ‘Node’ class needs to be created. In this class, there are three attributes, the data that is present in the node, the access to the next node of the linked list, and the access to the previous node of the linked list.Below is a demonstration for the same −Exampleclass Node:    def __init__(self, my_data):       self.previous = None       self.data = my_data       self.next = None class double_list:    def __init__(self):       self.head = ...

Read More

Python Program to Find the Area of a Rectangle Using Classes

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 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 the area of rectangle.Below is a demonstration for the same −Exampleclass shape_rectangle(): def __init__(self, my_length, my_breadth):    self.length = my_length    self.breadth = my_breadth def calculate_area(self):    return self.length*self.breadth len_val = 6 bread_val = 45 print("The length of the rectangle is : ") print(len_val) print("The breadth of the rectangle is ...

Read More

Python program to remove duplicate elements from a Doubly Linked List

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 321 Views

When it is required to remove the duplicate elements in a doubly linked list, a ‘Node’ class needs to be created. In this class, there are three attributes, the data that is present in the node, the access to the next node of the linked list, and the access to the previous node of the linked list.Below is a demonstration for the same −Exampleclass Node:    def __init__(self, my_data):       self.previous = None       self.data = my_data       self.next = None class double_list:    def __init__(self):       self.head = None     ...

Read More

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

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 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 are used to add elements to the list, delete elements from the list and display the elements of the list using objects.Below is a demonstration for the same −Exampleclass list_class():    def __init__(self):       self.n=[]    def add_val(self, a):       return self.n.append(a)    def remove_val(self, b): ...

Read More

Python program to rotate doubly linked list by N nodes

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 311 Views

When it is required to rotate a doubly linked list by a specific number of nodes, a ‘Node’ class needs to be created. In this class, there are three attributes, the data that is present in the node, the access to the next node of the linked list, and the access to the previous node of the linked list.Below is a demonstration for the same −Exampleclass Node:    def __init__(self, my_data):       self.previous = None       self.data = my_data       self.next = None class double_list:    def __init__(self):       self.head = None ...

Read More
Showing 661–670 of 8,547 articles
« Prev 1 65 66 67 68 69 855 Next »
Advertisements