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
Articles on Trending Technologies
Technical articles with clear explanations and examples
Python Program to Print all Numbers in a Range Divisible by a Given Number
When it is required to print all the elements in a given range that is divisible by a specific number, a simple for loop can be used along with the modulus operator. Below is a demonstration of the same − Example # Define range and divisor lower_num = 10 upper_num = 50 div_num = 7 print(f"Numbers between {lower_num} and {upper_num} divisible by {div_num}:") for i in range(lower_num, upper_num + 1): if i % div_num == 0: print(i) Numbers between 10 ...
Read MorePython Program to Input a Number n and Compute n+nn+nnn
In this tutorial, we'll write a Python program to input a number n and compute the sum n + nn + nnn. For example, if n = 4, we calculate 4 + 44 + 444 = 492. The key approach is to convert the number to a string and concatenate it to create the required patterns. Example Here's the complete program ? n = int(input("Enter a value for n: ")) n_str = str(n) # Create the patterns: nn and nnn nn = n_str + n_str nnn = n_str + n_str + n_str # ...
Read MorePython program to print the elements of an array present on even position
When it is required to print the elements of a list that are present at even index/position, a loop can be used to iterate over the elements, and only check the even positions in the list by specifying the step size as 2 in the range function. Below is a demonstration of the same − Example my_list = [31, 42, 13, 34, 85, 0, 99, 1, 3] print("The list is :") print(my_list) print("The elements in even positions are : ") for i in range(0, len(my_list), 2): print(my_list[i]) Output ...
Read MorePython program to print the elements of an array present on odd position
When we need to print elements at odd positions in a Python list, we can use a for loop with the range() function. By starting from index 1 and using a step size of 2, we can access only the odd-positioned elements. Using range() with Step Size The most common approach is to iterate through odd indices using range(1, len(list), 2) ? my_list = [31, 42, 13, 34, 85, 0, 99, 1, 3] print("The list is:") print(my_list) print("The elements in odd positions are:") for i in range(1, len(my_list), 2): print(my_list[i]) ...
Read MoreHow to use Boto3 to find whether a function can paginate or not in AWS Secret Manager
AWS Secrets Manager in boto3 provides pagination support for operations that return large result sets. The can_paginate() method helps determine if a specific operation supports pagination before implementing it. Understanding Pagination in AWS Secrets Manager Pagination allows you to retrieve large datasets in smaller, manageable chunks. Operations like list_secrets can return many results and support pagination, while operations like get_secret_value return single items and don't need pagination. Approach Step 1: Import boto3 and botocore exceptions to handle errors. Step 2: Create an AWS session and Secrets Manager client. Step 3: Use the can_paginate() method with ...
Read MoreHow to use Boto3 to remove tags in specified AWS secrets
AWS Secrets Manager allows you to store and manage sensitive information like database credentials and API keys. Using boto3, Python's AWS SDK, you can programmatically remove tags from secrets to manage metadata and organization. Prerequisites Before using this code, ensure you have ? AWS credentials configured (via AWS CLI, environment variables, or IAM roles) Boto3 library installed: pip install boto3 Proper IAM permissions for Secrets Manager operations Algorithm Step 1: Import boto3 and botocore exceptions to handle errors. Step 2: Define function parameters: secret_location (secret ARN or name) and tags_list (list of ...
Read MoreHow to use Boto3 to add tags in specified AWS secrets
AWS Secrets Manager allows you to store and manage sensitive information like database passwords and API keys. You can organize and categorize secrets using tags, which are key-value pairs that help with resource management and billing. The boto3 library provides a simple way to add tags to AWS secrets programmatically. Prerequisites Before adding tags to AWS secrets, ensure you have ? AWS credentials configured (via AWS CLI, environment variables, or IAM roles) The boto3 library installed: pip install boto3 Proper IAM permissions for Secrets Manager operations Understanding the Tag Format AWS Secrets Manager ...
Read MoreHow to use Boto3 to store a new secret in a specific location in AWS Secret Manager
AWS Secrets Manager is a service for securely storing and managing sensitive information like API keys, database credentials, and other secrets. Using the boto3 library in Python, you can programmatically store new secrets in specific locations within AWS Secrets Manager. Prerequisites Before storing secrets, ensure you have ? AWS credentials configured (via AWS CLI, IAM roles, or environment variables) Appropriate IAM permissions for Secrets Manager operations The boto3 library installed: pip install boto3 Algorithm to Store a New Secret Step 1: Import boto3 and botocore exceptions to handle errors properly. Step 2: ...
Read MoreHow to use Boto3 to get a list of all secrets in AWS Secret Manager
AWS Secrets Manager is a service that helps you protect secrets needed to access your applications. Using boto3, Python's AWS SDK, you can retrieve a list of all secrets stored in your AWS account programmatically. Prerequisites Before running the code, ensure you have − AWS credentials configured (via AWS CLI, IAM roles, or environment variables) boto3 library installed: pip install boto3 Appropriate IAM permissions for secretsmanager:ListSecrets Basic Example Here's how to get all secrets using the list_secrets() method ? import boto3 from botocore.exceptions import ClientError def get_all_secrets(): ...
Read MoreHow to use Boto3 to generate a random password in AWS Secret Manager
Problem Statement: Use boto3 library in Python to generate a random password in AWS Secrets Manager AWS Secrets Manager provides a get_random_password API that generates cryptographically secure random passwords. This is useful for creating strong passwords for database users, applications, or other AWS services. Prerequisites Before using this functionality, ensure you have: AWS credentials configured (via AWS CLI, IAM roles, or environment variables) Proper IAM permissions for secretsmanager:GetRandomPassword boto3 library installed: pip install boto3 Algorithm Steps Step 1: Import boto3 and botocore exceptions to handle exceptions. Step 2: Create an AWS ...
Read More