Python Scenarios

Python Scenarios

Real-world Python scenario-based interview questions covering debugging, performance optimization, API design, asyncio, and production-grade Python patterns.

21+
Scenarios
3
Difficulty Levels
100%
Free
21
Hands-on Labs
 Python

Scenario Labs

← All Scenarios
DIFFICULTY
python Intermediate Python
pythonboto3cost-optimization

Clean Up Unused AWS Resources — EBS Volumes, EIPs, Old AMIs with Cost Report

Python script to find and delete unattached EBS volumes, unassociated Elastic IPs, and old AMIs, then produce a JSON cost-savings report.

~20 min 6 steps 2 services
Free Start Scenario
python Advanced Python
pythonboto3best-practices

Production-Grade Python Scripts for AWS — Best Practices & Patterns

Code examples covering structured logging, credential management, idempotent operations, environment configuration, Secrets Manager integration, and graceful error handling.

~25 min 8 steps 4 services
Free Start Scenario
python Advanced Python
pythonboto3retry

boto3 Retry Decorator with Exponential Backoff for ThrottlingException

Python decorator that adds automatic retry logic with exponential backoff and jitter to any boto3 API call, handling ThrottlingException and transient AWS errors.

~20 min 5 steps 5 services
Free Start Scenario
python Intermediate Python
pythonboto3pagination

Generic boto3 Pagination Utility — Handle All Paginated AWS APIs

Python utility function that handles pagination for any boto3 API call generically, with automatic NextToken handling, filtering support, and a lazy generator interface.

~15 min 4 steps 5 services
Free Start Scenario
python Advanced Python
pythonboto3organizations

Multi-Account Security Report — Assume Roles Across All Org Accounts

Python script that uses AWS Organizations to list all accounts, assumes a cross-account role in each, audits security controls, and generates a consolidated report.

~30 min 8 steps 7 services
Free Start Scenario
python Intermediate Python
pythonboto3codepipeline

Trigger CodePipeline & Send Slack Notifications at Each Stage

Python script to start an AWS CodePipeline execution, poll stage progress, and post real-time Slack notifications as each stage succeeds, fails, or progresses.

~20 min 6 steps 3 services
Free Start Scenario
python Advanced Python
pythonboto3cloudtrail

CloudTrail Root Account Monitor — Alert on Root API Usage via Lambda

Lambda function triggered by EventBridge to detect any AWS root account API activity in CloudTrail and immediately send a critical security alert via SNS.

~20 min 6 steps 5 services
Free Start Scenario
python Advanced Python
pythonboto3ecs

ECS Rolling Deployment with Automatic Rollback on Health Check Failure

Python script to deploy a new container image to an ECS service with rolling update strategy, monitor health, and automatically roll back if the deployment fails.

~25 min 8 steps 4 services
Free Start Scenario
python Intermediate Python
pythonboto3security-groups

Security Group Audit — Find Unrestricted Inbound Rules (0.0.0.0/0)

Python script to audit all VPC Security Groups, identify rules that expose sensitive ports to the internet, and optionally auto-remediate critical findings.

~20 min 5 steps 4 services
Free Start Scenario
python Advanced Python
pythonboto3cost-explorer

EC2 Cost Analysis & Savings Plan Recommendations with Cost Explorer

Python script to analyse EC2 on-demand spend via AWS Cost Explorer and surface Savings Plan and Reserved Instance purchase recommendations with estimated savings.

~20 min 5 steps 3 services
Free Start Scenario
python Advanced Python
pythonboto3rds

RDS Snapshot Before Deployment & Point-in-Time Restore

Python script to create an RDS snapshot before every deployment and restore the database from that snapshot (or to a specific point in time) if a rollback is required.

~25 min 7 steps 3 services
Free Start Scenario
python Intermediate Python
pythonboto3cloudwatch

Create CloudWatch Alarms for All EC2 Instances (CPU, Memory, Disk)

Python script to create CloudWatch alarms for every running EC2 instance covering CPU utilization, status checks, memory usage (via CWAgent), and disk space.

~20 min 5 steps 5 services
Free Start Scenario
python Advanced Python
pythonboto3lambda

Deploy Lambda Function with Version Publishing & Alias Traffic Shifting

Python script to deploy or update a Lambda function, update environment variables, publish a new version, and create an alias with canary traffic shifting.

~25 min 7 steps 3 services
Free Start Scenario
python Advanced Python
pythonboto3iam

Generate Least-Privilege IAM Policy from CloudTrail Logs

Python script that analyses CloudTrail logs for a given IAM role and generates a minimal IAM policy containing only the actions the role actually used.

~25 min 6 steps 3 services
Free Start Scenario
python Intermediate Python
pythonboto3iam

IAM Access Key Rotation — Auto-Rotate Keys Older than 90 Days

Python script to find all IAM users with access keys older than 90 days, create new keys, deactivate old ones, and notify users via AWS SES.

~20 min 6 steps 4 services
Free Start Scenario
python Intermediate Python
pythonboto3s3

S3 Bucket Security Audit — Public Access, Versioning & Encryption

Python script to audit all S3 buckets for public access exposure, disabled versioning, missing encryption, and access logging gaps — with a compliance report.

~20 min 5 steps 4 services
Free Start Scenario
python Intermediate Python
pythonboto3s3

Sync Local Directory to S3 with KMS Encryption & Manifest

Python script to sync a local directory to S3, encrypt every file with a KMS key, skip unchanged files via MD5 check, and produce a JSON upload manifest.

~20 min 6 steps 4 services
Free Start Scenario
python Intermediate Python
pythonboto3ec2

Find Untagged Long-Running EC2 Instances & Alert via SES

Python script to find EC2 instances running for more than 7 days without a Project tag and send a compliance alert email using AWS SES.

~15 min 5 steps 4 services
Free Start Scenario
python Intermediate Python
pythonboto3ebs

EBS Snapshot Manager — Auto Backup & Retention Cleanup

Write a Python boto3 script to snapshot all EBS volumes attached to running EC2 instances and automatically delete snapshots older than 30 days.

~20 min 6 steps 4 services
Free Start Scenario
python Advanced Python
pythonscenarioperformance

Python Scenario-Based Interview Questions

Real-world Python scenario questions covering debugging, performance, API design, asyncio concurrency, memory optimization, and production-grade patterns.

~30 min 10 steps 5 services
Free Start Scenario
python Intermediate Python
pythonboto3ec2

Auto Stop/Start EC2 Instances Using Schedule Tags with Python

Write a Python boto3 script that reads the AutoStop=true tag on EC2 instances and automatically stops them at 8 PM and starts them at 8 AM — with detailed explanation of every command.

~20 min 8 steps 5 services
Free Start Scenario

🧩 Suggest a Real-World Scenario

Faced an interesting production incident or challenge? Share it so others can learn from it too.