APURV
  • Home
  • Journey
  • Projects
  • Blogs
  • Interview
  • Exams
Resume
APURV

Building scalable, secure, and production-ready cloud infrastructure. Automation first.

NAVIGATION

HomeExperienceProjectsCertificationsSkills

TECH STACK

AWSGCPK8sCI/CDLinuxDocker

CONNECT

LinkedInGitHubEmailResume

© 2026 Apurv Gujjar. All rights reserved.
Apurv Gujjar
Apurv GujjarDevOps & Cloud Engineer
|Interview Documentation
Portfolio
Handbooks
🎯Linux🐙Git & GitHub🤖GitHub Actions🌐Networking☁AWS🛠Terraform🐳Docker☸Kubernetes📊Monitoring🛡DevSecOps💰Cost Optimization🚨Incident Scenarios👤HR & Behavioral☁GCP🐍Python
Interview DocumentationPythonScenario 4: Write a script that parses an application log file, extracts all "ERROR" entries, and generates a formatted markdown report.
Back to all Python questions
Q4

Scenario 4: Write a script that parses an application log file, extracts all "ERROR" entries, and generates a formatted markdown report.

💬Answer
log_file = "app.log"
report_file = "error_report.md"

errors = []

# 1. Read and find errors
with open(log_file, "r") as f:
    for line in f:
        if "ERROR" in line:
            errors.append(line.strip())

# 2. Write Markdown report
with open(report_file, "w") as f:
    f.write("# 📋 DevOps Log Incident Report\n\n")
    f.write(f"**Source Log File:** `{log_file}`  \n")
    f.write(f"**Total Incidents Found:** {len(errors)}  \n\n")
    f.write("## ⚠️ Identified Exceptions:\n")
    if errors:
        for idx, error in enumerate(errors, 1):
            f.write(f"{idx}. `{error}`\n")
    else:
        f.write("*No errors detected in the current log range.*\n")

print(f"Report compiled successfully at {report_file}")

Related Python Questions

View All PythonQuestions →
Q1

What is the difference between a List and a Tuple?

Q2

What is the difference between the `==` and `is` operators?

Q3

What are the primary Python data types?

Q4

What is a dictionary and why is it heavily used in DevOps?

Apurv Gujjar - DevOps & Cloud Engineer
Created by

Apurv Gujjar

DevOps & Cloud Engineer

Specialized in:DevOpsAWSGCPKubernetesTerraformDocker
View Portfolio