Python Automation Basics · Course lab · about 240 minutes · 6 tasks · marked out of 100, pass at 60
One report that runs itself, safely, for a real person
The situation
Three branches of a small academy send their registers as separate spreadsheets every week, dirty in the usual ways, and somebody spends a morning merging them. Build the automation that does it: clean with a printed report, merge, produce the workbook, email it, run every day on a schedule — and fail loudly when the input is missing. Then ship it to a real person and show them the first run.
What you'll be able to show
- Choose automation targets by cost-to-effort ratio
- Clean data with a printed before/after report, never silently
- Schedule a script and prove its failure is visible
- Keep secrets in .env and out of the repository
What you need
- Python 3 with pandas and openpyxl, a .env file
- Windows Task Scheduler (or cron)
- An email account with an app password, and a free JSON API
Tasks
-
1The hit-listList five repetitive computer tasks you or someone near you does. For each: how often, minutes each time, yearly cost in hours. Star the two with the best cost-to-scripting-effort ratio.A correct result: A five-row table with yearly hours and two starred rows.
-
2Three dirty registers, one clean mergeFake three branch registers (10 rows each: one city misspelled, one amount as text, one blank row). Write merge_report.py: glob, read, CLEAN with printed before/after counts, concat, write combined.xlsx plus a per-course summary sheet.A correct result: combined.xlsx with two sheets, and a printed cleaning report an office could trust.
-
3Date-stamp, log, scheduleDate-stamp the output filename. Add logging: one OK line per run with counts; a FAILED line with the reason on exception. Schedule it daily. Confirm from its own log that it fired at the local time you intended.A correct result: A log with a dated OK line from a scheduled run.
-
4Break the input on purposeRename the input folder and let the schedule fire. Confirm the failure is visible in the log AND in an error signal you would actually notice — not just an absent file.A correct result: A FAILED log line and the error signal you received.
-
5Email it, with a fetch that cannot kill itSend combined.xlsx to yourself on each run via smtplib, with the app password in .env and .env in .gitignore (verify with git status). Add one fetch from a free JSON API into the email body, with a timeout and a try/except that logs but does not stop the report.A correct result: The email received with the attachment; git status shows .env untracked; the fetch failure test logs and the email still goes.
-
6Ship it to a real personTake your starred task that belongs to a real person (a family shop, a colleague, or your own weekly chore). Build it with all four rules — dry-run, report, log with loud failure, .env — schedule it, and show them the first successful run. Write three honest lines in the README about what it saves.A correct result: A second automation, scheduled, demonstrated to its owner, with three README lines.
What to hand in
The repo (with .env excluded), the log showing a scheduled OK run and a FAILED run, the received email, and the README lines for the shipped automation.
How it is marked
| Criterion | Points |
|---|---|
| Hit-list is quantified and two targets chosen | 10 |
| Merge cleans with a printed, trustworthy report | 20 |
| Scheduled run with dated log proven | 15 |
| Failure is loud in the log and an error signal | 15 |
| Email works, .env excluded, fetch cannot kill the report | 20 |
| Second automation shipped to a real person | 20 |
| Total · pass at 60 | 100 |
صورتحال
ایک چھوٹی academy کی تین branches ہر ہفتے اپنے registers الگ الگ spreadsheets میں بھیجتی ہیں، معمول کے طریقوں سے گندے، اور کوئی ایک صبح انہیں ملانے میں لگاتا ہے۔ وہ automation بنائیں جو یہ کرے: print کی ہوئی report کے ساتھ صاف کرے، ملائے، workbook بنائے، email کرے، ہر روز schedule پر چلے — اور input غائب ہو تو زور سے ناکام ہو۔ پھر اسے ایک حقیقی شخص کو دیں اور انہیں پہلا run دکھائیں۔
آپ کیا دکھا سکیں گے
- لاگت-بمقابلہ-محنت کے تناسب سے automation کے ہدف چننا
- پہلے/بعد کی print شدہ report کے ساتھ data صاف کرنا، کبھی خاموشی سے نہیں
- script کو schedule کرنا اور ثابت کرنا کہ اس کی ناکامی نظر آتی ہے
- secrets کو .env میں اور repository سے باہر رکھنا
آپ کو کیا چاہیے
- pandas اور openpyxl کے ساتھ Python 3، ایک .env file
- Windows Task Scheduler (یا cron)
- app password والا email account، اور ایک مفت JSON API
کام
-
1hit-listپانچ بار بار ہونے والے computer کے کام لکھیں جو آپ یا آپ کے قریب کوئی کرتا ہے۔ ہر ایک کے لیے: کتنی بار، ہر بار کتنے منٹ، سالانہ لاگت گھنٹوں میں۔ لاگت-بمقابلہ-scripting-محنت کے بہترین تناسب والے دو پر ستارہ لگائیں۔درست نتیجہ: سالانہ گھنٹوں والی پانچ قطاروں کی table اور دو ستارے والی قطاریں۔
-
2تین گندے registers، ایک صاف mergeتین branch registers فرض کریں (ہر ایک میں 10 قطاریں: ایک شہر غلط spelling میں، ایک رقم text میں، ایک خالی قطار)۔ merge_report.py لکھیں: glob، read، print شدہ پہلے/بعد کی گنتی کے ساتھ CLEAN، concat، combined.xlsx اور per-course summary sheet لکھیں۔درست نتیجہ: دو sheets والا combined.xlsx، اور ایسی print شدہ cleaning report جس پر دفتر بھروسہ کر سکے۔
-
3تاریخ، log، scheduleoutput filename پر تاریخ لگائیں۔ logging شامل کریں: ہر run پر گنتی کے ساتھ ایک OK line؛ exception پر وجہ کے ساتھ FAILED line۔ روزانہ schedule کریں۔ اس کے اپنے log سے تصدیق کریں کہ وہ اسی مقامی وقت پر چلا جو آپ چاہتے تھے۔درست نتیجہ: schedule شدہ run کی تاریخ والی OK line کے ساتھ log۔
-
4input جان بوجھ کر توڑیںinput folder کا نام بدلیں اور schedule کو چلنے دیں۔ تصدیق کریں کہ ناکامی log میں اور ایسے error signal میں نظر آتی ہے جس پر آپ واقعی توجہ دیں — نہ کہ بس ایک غائب file۔درست نتیجہ: ایک FAILED log line اور وہ error signal جو آپ کو ملا۔
-
5email کریں، ایسے fetch کے ساتھ جو اسے مار نہ سکےہر run پر smtplib سے combined.xlsx خود کو بھیجیں، app password .env میں اور .env .gitignore میں (git status سے تصدیق کریں)۔ email کے متن میں کسی مفت JSON API سے ایک fetch شامل کریں، timeout اور ایسے try/except کے ساتھ جو log کرے مگر report نہ روکے۔درست نتیجہ: attachment کے ساتھ email موصول؛ git status .env کو untracked دکھائے؛ fetch کی ناکامی کا test log ہو اور email پھر بھی جائے۔
-
6حقیقی شخص کو دیںاپنا وہ ستارے والا کام لیں جو کسی حقیقی شخص کا ہے (خاندانی دکان، ساتھی، یا آپ کا اپنا ہفتہ وار کام)۔ چاروں اصولوں کے ساتھ بنائیں — dry-run، report، زوردار ناکامی والا log، .env — schedule کریں، اور انہیں پہلا کامیاب run دکھائیں۔ README میں تین ایماندار lines لکھیں کہ یہ کیا بچاتا ہے۔درست نتیجہ: دوسری automation، schedule شدہ، اپنے مالک کو دکھائی گئی، README کی تین lines کے ساتھ۔
کیا جمع کروانا ہے
repo (.env خارج)، schedule شدہ OK run اور FAILED run دکھاتا log، موصول شدہ email، اور بھیجی گئی automation کی README lines۔
نمبر کیسے ملیں گے
| معیار | نمبر |
|---|---|
| hit-list نمبروں میں ہے اور دو ہدف چنے گئے | 10 |
| merge print شدہ، قابلِ اعتماد report کے ساتھ صاف کرتا ہے | 20 |
| schedule شدہ run تاریخ والے log سے ثابت | 15 |
| ناکامی log اور error signal میں زوردار ہے | 15 |
| email کام کرتی ہے، .env خارج، fetch report کو مار نہیں سکتا | 20 |
| دوسری automation حقیقی شخص کو دی گئی | 20 |
| کل · پاس 60 | 100 |
Hand in your lab
Create a free BvLogic ID to hand in your lab, get it marked, and have it on your certificate.
Create your BvLogic IDAlready have one? Sign in and this course will be added to it.