Posts

Showing posts with the label List Comprehension

Featured Post

How to Build CI/CD Pipeline: GitHub to AWS

Image
 Creating a CI/CD pipeline to deploy a project from GitHub to AWS can be done using various AWS services like AWS CodePipeline, AWS CodeBuild, and optionally AWS CodeDeploy or Amazon ECS for application deployment. Below is a high-level guide on how to set up a basic GitHub to AWS pipeline: Prerequisites AWS Account : Ensure access to the AWS account with the necessary permissions. GitHub Repository : Have your application code hosted on GitHub. IAM Roles : Create necessary IAM roles with permissions to interact with AWS services (e.g., CodePipeline, CodeBuild, S3, ECS, etc.). AWS CLI : Install and configure the AWS CLI for easier management of services. Step 1: Create an S3 Bucket for Artifacts AWS CodePipeline requires an S3 bucket to store artifacts (builds, deployments, etc.). Go to the S3 service in the AWS Management Console. Create a new bucket, ensuring it has a unique name. Note the bucket name for later use. Step 2: Set Up AWS CodeBuild CodeBuild will handle the build proces

2 Tricky Examples Python List Comprehension

Image
Here are the tricky examples of list comprehension. These examples useful for your project and interviews as well. 1. Printing odd numbers Reminder checking logic used here. If it is not equal to zero when you divide the number with 2, it treats the input number as odd and prints it. lst1 = [x for x in range(40) if x % 2 != 0] print('First 20 Odd Numbers:') print(lst1) 2. Printing even numbers Reminder checking logic used here. If it is equal to zero when you divide the number with 2, it treats the input number as even and prints it. lst2 = [x for x in range(40) if x % 2 == 0] print('First 20 Even Numbers:') print(lst2) Output from the Python scripts First 20 Odd Numbers:  [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39] First 20 Even Numbers:  [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38]  ** Process exited - Return Code: 0 ** Press Enter to exit terminal Related The real use of Git in Dev Ops