
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 10476 Articles for Python

209 Views
Problem Statement: Use boto3 library in Python to restore all secret keys from specific location in AWS Secret Manager.Approach/Algorithm to solve this problemStep 1: Import boto3 and botocore exceptions to handle exceptions.Step 2: secret_stored_location is the required parameter.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 the session.Step 4: Create an AWS client for secretmanager.Step 5: Call restore_secret and pass the secret_stored_location as SecretId.Step 6: It returns the metadata of restored secret.Step 7: Handle the generic exception if something ... Read More

409 Views
Problem Statement: Use boto3 library in Python to delete all secret keys from a specific location in AWS Secret ManagerApproach/Algorithm to solve this problemStep 1: Import boto3 and botocore exceptions to handle exceptions.Step 2: secret_stored_location is the required parameter.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 the session.Step 4: Create an AWS client for secretmanager.Step 5: Call delete_secret and pass the secret_stored_location as SecretId.Step 6: It returns the metadata of deleted secret.Step 7: Handle the generic exception if ... Read More

1K+ Views
Problem Statement: Use boto3 library in Python to create a secret key as plain text in AWS Secret ManagerApproach/Algorithm to solve this problemStep 1: Import boto3 and botocore exceptions to handle exceptions.Step 2: secret_stored_location and secret_key_pair is the required parameter. It is a place where secrets are saved with given key-pair value. Make sure secret_key_pair is written as string, not as dict. For example: '{key:pair}'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 the session.Step 4: Create an AWS ... Read More

684 Views
Problem Statement: Use boto3 library in Python to get the secret keys as plain text from binary/encrypted format present in AWS Secret ManagerApproach/Algorithm to solve this problemStep 1: Import boto3 and botocore exceptions to handle exceptions.Step 2: secret_stored_location is the required parameter. It is a place where secrets are saved.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 the session.Step 4: Create an AWS client for secretmanager.Step 5: Call get_secret_value and pass the secret_stored_location as SecretId.Step 6: Check whether ... Read More

1K+ Views
Problem Statement: Use boto3 library in Python to get secret keys from AWS Secret ManagerApproach/Algorithm to solve this problemStep 1: Import boto3 and botocore exceptions to handle exceptions.Step 2: secret_stored_location is the required parameter. It is a place where secrets are saved.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 the session.Step 4: Create an AWS client for secretmanager.Step 5: Call get_secret_value and pass the secret_stored_location as SecretId.Step 6: It returns all the secrets that are present without encryption ... Read More

331 Views
Problem Statement: Use boto3 library in Python to paginate through multi-part upload objects of a S3 bucket from AWS Glue Data Catalog that is created in your accountApproach/Algorithm to solve this problemStep 1: Import boto3 and botocore exceptions to handle exceptions.Step 2: prefix_name, max_items, page_size and starting_token is optional parameter for this function while bucket_name is required parameters.Prefix_name is the specific sub folders where user wants to paginate throughmax_items denote the total number of records to return. If the number of available records > max_items, then a NextToken will be provided in the response to resume pagination.page_size denotes the size ... Read More

4K+ Views
Problem Statement: Use boto3 library in Python to paginate through all objects of a S3 bucket from AWS Glue Data Catalog that is created in your accountApproach/Algorithm to solve this problemStep 1: Import boto3 and botocore exceptions to handle exceptions.Step 2: max_items, page_size and starting_token are the optional parameters for this function, while bucket_name is the required parameter.max_items denote the total number of records to return. If the number of available records > max_items, then a NextToken will be provided in the response to resume pagination.page_size denotes the size of each page.starting_token helps to paginate, and it uses last key ... Read More

1K+ Views
When it is required to copy all the elements from one array to another, an empty array with ‘None’ elements is created. A simple for loop is used to iterate over the elements, and the ‘=’ operator is used to assign values to the new list.Below is a demonstration of the same −Example Live Demomy_list_1 = [34, 56, 78, 90, 11, 23] my_list_2 = [None] * len(my_list_1) for i in range(0, len(my_list_1)): my_list_2[i] = my_list_1[i] print("The list is : ") for i in range(0, len(my_list_1)): print(my_list_1[i]) print() print("The new list : ") for i in ... Read More

640 Views
When it is required to construct a binary tree, and perform operations such as inserting an element, deleting an element and displaying elements of the tree, a class is defined with methods in it. An instance of the class is defined and this is used to access the elements and perform operations.Below is a demonstration of the same −Example Live Democlass Tree_struct: def __init__(self, data=None, parent=None): self.key = data self.children = [] self.parent = parent def set_root(self, data): self.key = data def add_node(self, node): ... Read More

212 Views
When it is required to check if a number has consecutive zeroes of a specific base, a method is defined, that takes the number and base as parameters, and uses another method to return Yes or No depending on whether the base is present or not.Below is a demonstration of the same −Example Live Demodef check_consecutive_zero(N, K): my_result = convert_to_base(N, K) if (check_n(my_result)): print("Yes") else: print("No") def convert_to_base(N, K): weight = 1 s = 0 while (N != 0): r = N % K ... Read More