Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Python Articles
Page 67 of 855
Python program to find the maximum and minimum value node from a doubly linked list
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 MorePython program to insert a new node at the beginning of the Doubly Linked list
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 MorePython Program to Edit objects inside tuple
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 MorePython program to insert a new node at the end of the Doubly Linked List
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 MorePython | Remove empty tuples from a list
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 MorePython program to insert a new node at the middle of the Doubly Linked List
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 MorePython Program to Find the Area of a Rectangle Using Classes
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 MorePython program to remove duplicate elements from a Doubly Linked List
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 MorePython Program to Append, Delete and Display Elements of a List Using Classes
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 MorePython program to rotate doubly linked list by N nodes
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