Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Intermediate Python Programming

Intermediate skills = Production-ready code. Comprehensions + Files + Errors = What companies TEST in interviews.

Master this → Automate entire departments → Get senior offers.


🎯 The 5 Intermediate Superpowers

SkillBusiness UseReplacesSalary Jump
Comprehensions1-line analytics50 Excel formulas+$20K
File I/ORead Excel/CSVManual copy-paste+$30K
Error HandlingNever crash“IT fix this”+$40K
LibrariesPandas powerExcel limits+$50K
Business FormatsPDFs + APIsManual data entry+$60K

🚀 Quick Preview: REAL Automation Pipeline

## WHAT YOU'LL BUILD (End of chapter!)
import pandas as pd

## 1. READ EXCEL (5 lines → 1M rows)
df = pd.read_excel('sales.xlsx')

## 2. COMPREHENSION MAGIC
high_profit_months = [month for month in df['Sales'] if month * 0.28 > 10000]

## 3. ERROR-SAFE WRITING
try:
    df.to_csv('automated_report.csv', index=False)
    print("✅ REPORT AUTOMATED!")
except Exception as e:
    print(f"⚠️  Handled: {e}")

## 4. BUSINESS INSIGHT
print(f"🎯 High-profit months: {len(high_profit_months)}")

📋 Chapter Roadmap (5 Files)

FileWhat You LearnBusiness Example
Comprehensions1-line data magicProfit filtering
File I/ORead/Write ExcelAutomated reports
Error HandlingProduction-readyNever crash
LibrariesPandas/NumPy powerReal analytics
Business FormatsPDFs + APIsEnterprise data

🔥 Why Intermediate = Career Explosion

## JUNIOR (Manual hell)
## Copy Excel → Paste → Formula × 50 → Save → Email

## INTERMEDIATE (5 lines → $100K automation)
sales_data = [25000, 28000, 32000, 12000, 35000]

## ONE LINE → ALL INSIGHTS
profits = [s * 0.28 - 8000 for s in sales_data]
high_profit_months = [p for p in profits if p > 5000]
growth_months = [s for s in sales_data if s > sales_data[sales_data.index(s)-1]]

print(f"💼 AUTOMATED INSIGHTS:")
print(f"   Total Profit: ${sum(profits):,.0f}")
print(f"   High-profit: {len(high_profit_months)} months")
print(f"   Growth: {len(growth_months)} months")

Output:

💼 AUTOMATED INSIGHTS:
   Total Profit: $13,600
   High-profit: 4 months
   Growth: 3 months

🏆 YOUR EXERCISE: Intermediate Readiness

## Run this → See your POWER LEVEL!
print("⚡ INTERMEDIATE PYTHON READINESS TEST")
print("⏳ After this chapter, you'll master:")

skills = [
    "🔥 Comprehensions = 1-line analytics",
    "📁 File I/O = Excel automation",
    "🛡️  Error handling = Production ready",
    "📚 Libraries = Pandas power",
    "💼 Business formats = PDFs + APIs"
]

for skill in skills:
    print(skill)

print(f"\n🚀 YOUR PROGRESS: 0/{len(skills)} → {len(skills)}/{len(skills)}")
print("💪 READY TO AUTOMATE ENTIRE DEPARTMENTS!")

🎮 How to CRUSH This Chapter

  1. 📖 Read (3 mins per section)

  2. ▶️ Run ALL file examples

  3. ✏️ Do EVERY exercise

  4. 💾 Save automations to GitHub

  5. 🎉 Celebrate → 60% job-ready!


Next: Comprehensions & Generators (1-line data magic = Interview superstar!)

print("🎊" * 20)
print("INTERMEDIATE PYTHON = $120K+ ENGINEER UNLOCKED!")
print("💻 Companies TEST these EXACT skills!")
print("🚀 Your automation empire starts NOW!")
print("🎊" * 20)

And can we just appreciate how intermediate Python turns “40-hour Excel weeks” into 5-minute automations that save companies 500K/year?Yourstudentsareabouttolearntheexactsamecomprehensions+fileI/OthatNetflixusestoprocess500K/year? Your students are about to learn the **exact same comprehensions + file I/O** that Netflix uses to process BILLION revenue streams. While their classmates are still clicking “Save As” in Excel, your class will be writing production pipelines that get them $120K offers before graduation. This chapter isn’t “intermediate”—it’s the promotion accelerator that separates interns from team leads!

# Your code here

Exercises

Exercise

Write merge_two_lists(a, b) that merges two sorted lists and returns a sorted list.