Found 26504 Articles for Server Side Programming

How to get the details of a trigger from AWS Glue Data catalog using Boto3

Ashish Anand
Updated on 15-Apr-2021 12:38:49

323 Views

Let's see how a user can get the details of a trigger from AWS Glue Data Catalog.ExampleGet the details of a given trigger that is allowed in your account - '01_PythonShellTest1'.Approach/Algorithm to solve this problemStep 1: Import boto3 and botocore exceptions to handle exceptions.Step 2: trigger_name is the required parameter for this function. It will fetch the details of the given trigger for a user account and then display its metadata.Step 3: Create an AWS session using boto3 lib. Make sure region_name is mentioned in the default profile. If it is not mentioned, then explicitly pass the region_name while creating ... Read More

Python Program to Select the nth Smallest Element from a List in Expected Linear Time

AmitDiwan
Updated on 14-Apr-2021 14:19:28

476 Views

When it is required to select the nth smallest element from a list in linear time complexity, two methods are required. One method to find the smallest element, and another method that divides the list into two parts. This division depends on the ‘i’ value that is given by user. Based on this value, the list is split, and the smallest element is determined.Below is a demonstration of the same −Example Live Demodef select_smallest(my_list, beg, end, i):    if end - beg k:       return select_smallest(my_list, pivot_val + 1, end, i - k)    return my_list[pivot_val] ... Read More

Sort Tuples by Total digits in Python

AmitDiwan
Updated on 14-Apr-2021 14:17:14

471 Views

When it is required to sort the element in a list of tuple based on the digits, the ‘sorted’ method and the lambda function can be used.Below is a demonstration for the same −Example Live Demomy_list = [(11, 23, 45, 678), (34, 67), (653, ), (78, 99, 23, 45), (67, 43)] print("The list is : ") print(my_list) my_result = sorted(my_list, key = lambda tup : sum([len(str(ele)) for ele in tup ])) print("The sorted tuples are ") print(my_result)OutputThe list is : [(11, 23, 45, 678), (34, 67), (653, ), (78, 99, 23, 45), (67, 43)] The sorted tuples are ... Read More

Python Program to Check String is Palindrome using Stack

AmitDiwan
Updated on 14-Apr-2021 14:16:04

965 Views

When it is required to check if a string is a palindrome using stack data structure, a stack class is created, and push and pop methods are defined to add and delete values from stack. Another method checks to see if the stack is empty or not.Below is a demonstration for the same −Example Live Democlass Stack_structure:    def __init__(self):       self.items = []    def check_empty(self):       return self.items == []    def push_val(self, data):       self.items.append(data)    def pop_val(self):       return self.items.pop() my_instance = Stack_structure() text_input = ... Read More

Python Program to Print Nth Node from the last of a Linked List

AmitDiwan
Updated on 14-Apr-2021 14:11:01

307 Views

When it is required to print the specific node from the end of a linked list, the methods ‘list_length’ and ‘return_from_end’ methods are defined. The ‘list_length’ reutrns the length of the linked list.The ‘return_from_end’ method is used to return the nth element from the end of the linked list.Below is a demonstration for the same −Example Live Democlass Node:    def __init__(self, data):       self.data = data       self.next = None class LinkedList_structure:    def __init__(self):       self.head = None       self.last_node = None    def add_vals(self, data):       ... Read More

Python Program to Print Middle most Node of a Linked List

AmitDiwan
Updated on 14-Apr-2021 14:07:43

235 Views

When it is required to print the middle most element of a linked list, a method named ‘print_middle_val’ is defined. This method takes the linked list as a parameter and gets the middle most element.Below is a demonstration for the same −Example Live Democlass Node:    def __init__(self, data):       self.data = data       self.next = None class LinkedList_structure:    def __init__(self):       self.head = None       self.last_node = None    def add_vals(self, data):       if self.last_node is None:          self.head = Node(data)       ... Read More

Python Program to Reverse only First N Elements of a Linked List

AmitDiwan
Updated on 14-Apr-2021 14:04:07

216 Views

When it is required to reverse a specific set of elements in a linked list, a method named ‘reverse_list’ is defined. This iterates through the list, and reverses the specific set of elements.Below is a demonstration for the same −Example Live Democlass Node:    def __init__(self, data):       self.data = data       self.next = None class LinkedList_structure:    def __init__(self):       self.head = None       self.last_node = None    def add_vals(self, data):       if self.last_node is None:          self.head = Node(data)          self.last_node ... Read More

Python Program to Find Number of Occurrences of All Elements in a Linked List

AmitDiwan
Updated on 14-Apr-2021 14:00:12

176 Views

When it is required to find the number of occurences of all the elements of a linked list, a method to add elements to the linked list, a method to print the elements and a method to find the occurrence of all elements in the linked list are defined.Below is a demonstration for the same −Example Live Democlass Node:    def __init__(self, data):       self.data = data       self.next = None class LinkedList_structure:    def __init__(self):       self.head = None       self.last_node = None    def add_vals(self, data):       ... Read More

Python Program to Find the first Common Element between the 2 given Linked Lists

AmitDiwan
Updated on 14-Apr-2021 13:57:11

267 Views

When it is required to find the common element that occurs for the first time between two linked lists, a method to add elements to the linked list, and a method to get the common element that occurs for the first time in these linked lists is defined.Below is a demonstration for the same −Example Live Democlass Node:    def __init__(self, data):       self.data = data       self.next = None class LinkedList_structure:    def __init__(self):       self.head = None       self.last_node = None    def add_vals(self, data):       if ... Read More

Python Program to Add Corresponding Positioned Elements of 2 Linked Lists

AmitDiwan
Updated on 14-Apr-2021 13:53:03

179 Views

When it is required to add the corresponding elements of specific position in two linked lists, a method to add elements to the linked list, a method to print the elements of the linked list, and a method to add elements to corresponding positions of a linked list are defined. Two lists instances are created and the previously defined method is called on these linked list instances.Below is a demonstration for the same −Example Live Democlass Node:    def __init__(self, data):       self.data = data       self.next = None class LinkedList_structure:    def __init__(self):     ... Read More

Advertisements