Python for Beginners · Course lab · about 120 minutes · 7 tasks · marked out of 100, pass at 60
Build the result system for a real academy
The situation
Sir Imran runs a computer academy in Sialkot with forty students in two batches. Marks, attendance and fee status live in a notebook, and every month he spends an evening working out by hand who passed, who earns a certificate (marks of 50 or more AND attendance of 75% or more AND fee paid), and what the class average was.
He wants a program that does all of it from a list he can edit himself — and that he can change when the rules change, without asking anybody.
What you'll be able to show
- Hold real records in a list of dictionaries and loop over them
- Put every rule in one function, so a rule change is a one-line edit
- Read an error message and fix the line it names
- Show a working program to somebody else and explain each part
What you need
- Any free online Python editor — nothing to install (the one linked in your BvLogic dashboard is fine)
- The code from lessons 5, 6 and 8
- A notes file for your test cases and the errors you meet
Tasks
-
1Build the dataCreate a list called students holding twelve dictionaries, each with name, city, marks, attendance and fee_paid (True or False). Make three of them deliberately awkward: one with attendance below 75 but marks above 50, one with marks below 50, and one with fee_paid set to False.A correct result: print(len(students)) shows 12, and you can point at the three awkward records by name.
-
2Write grade(marks)A function that returns "A" for 80 and above, "B" for 65 and above, "Pass" for 50 and above, and "Fail" otherwise. Call it four times: 85, 65, 50, 49.A correct result: The four calls print A, B, Pass, Fail — in that order, with 50 and 49 on opposite sides of the line.
-
3Write gets_certificate(student)A function that takes one student dictionary and returns True only when marks are 50 or more, attendance is 75 or more, and fee_paid is True. The rule lives here and nowhere else.A correct result: Your three awkward students return False; an ordinary passing student returns True.
-
4The monthly reportLoop over students and print one line each in the shape: Name (City): marks — grade — certificate or no certificate. Use your two functions; do not repeat their rules inside the loop.A correct result: Twelve lines, and the three exceptions are readable at a glance without scrolling back to the data.
-
5The numbers Sir Imran asks forAfter the loop, print the class average to one decimal place, how many students earned a certificate, and the top scorer's name from a function highest(students) that returns the name.A correct result: Three lines. Change one student's marks and run again: the average and possibly the top scorer change, and nothing else breaks.
-
6The rule changeThe academy lowers the attendance requirement from 75 to 70. Make the change by editing exactly one line, run the report again, and write down which line you edited and what changed in the output.A correct result: One edited line. If you had to change more than one, the rule was copied somewhere it should not have been — fix that first.
-
7Break it on purposeRemove a colon from an if line, run, read the error and fix it. Then remove one quotation mark, run, read the error and fix it. Copy both error messages into your notes with the line number each one named.A correct result: Two error messages in your notes, each naming a line, each fixed in under a minute.
What to hand in
Your .py file (or a share link from the online editor), the printed report pasted in, and five sentences: what grade() does, what gets_certificate() does, what highest() does, which single line you changed in task 6, and which of the two errors was harder to read.
How it is marked
| Criterion | Points |
|---|---|
| Data built correctly, with the three awkward records present and named | 15 |
| grade() and gets_certificate() are correct and each rule lives in exactly one place | 30 |
| Report loop prints one clear line per student using the functions | 20 |
| Average, certificate count and top scorer are correct | 20 |
| The rule change was one line, and the five sentences are clear | 15 |
| Total · pass at 60 | 100 |
صورتحال
سر عمران سیالکوٹ میں ایک computer academy چلاتے ہیں جس میں دو batches میں چالیس students ہیں۔ marks، attendance اور فیس کی حالت ایک notebook میں لکھی ہوتی ہے، اور ہر مہینے وہ ایک شام ہاتھ سے یہ نکالنے میں لگاتے ہیں کہ کون pass ہوا، کسے certificate ملے گا (marks 50 یا زیادہ اور attendance 75% یا زیادہ اور فیس ادا)، اور کلاس کی average کیا رہی۔
وہ ایک ایسا program چاہتے ہیں جو یہ سب ایک ایسی list سے کر دے جسے وہ خود edit کر سکیں — اور جسے اصول بدلنے پر وہ کسی سے پوچھے بغیر خود بدل سکیں۔
آپ کیا دکھا سکیں گے
- حقیقی records کو dictionaries کی list میں رکھنا اور ان پر loop چلانا
- ہر اصول کو ایک function میں رکھنا، تاکہ اصول بدلنا ایک line کی edit ہو
- error message پڑھ کر وہی line ٹھیک کرنا جس کا وہ نام لیتا ہے
- چلتا ہوا program کسی کو دکھانا اور ہر حصہ سمجھانا
آپ کو کیا چاہیے
- کوئی بھی مفت online Python editor — کچھ install نہیں کرنا (آپ کے BvLogic dashboard میں دیا ہوا لنک ٹھیک ہے)
- سبق 5، 6 اور 8 کا code
- اپنے test cases اور ملنے والے errors کے لیے ایک notes file
کام
-
1data بنائیںstudents نام کی ایک list بنائیں جس میں بارہ dictionaries ہوں، ہر ایک میں name، city، marks، attendance اور fee_paid (True یا False)۔ تین کو جان بوجھ کر مشکل بنائیں: ایک جس کی attendance 75 سے کم مگر marks 50 سے زیادہ ہوں، ایک جس کے marks 50 سے کم ہوں، اور ایک جس کا fee_paid False ہو۔درست نتیجہ: print(len(students)) بارہ دکھائے، اور آپ تینوں مشکل records کو نام سے بتا سکیں۔
-
2grade(marks) لکھیںایک function جو 80 یا اوپر پر "A"، 65 یا اوپر پر "B"، 50 یا اوپر پر "Pass" اور باقی پر "Fail" واپس کرے۔ اسے چار بار call کریں: 85، 65، 50، 49۔درست نتیجہ: چاروں calls اسی ترتیب میں A، B، Pass، Fail print کریں — 50 اور 49 لکیر کے مخالف طرف ہوں۔
-
3gets_certificate(student) لکھیںایک function جو ایک student dictionary لے اور صرف تب True واپس کرے جب marks 50 یا زیادہ ہوں، attendance 75 یا زیادہ ہو، اور fee_paid True ہو۔ یہ اصول یہیں رہے، اور کہیں نہیں۔درست نتیجہ: آپ کے تینوں مشکل students پر False آئے؛ ایک عام pass student پر True۔
-
4ماہانہ reportstudents پر loop چلائیں اور ہر ایک کے لیے ایک line print کریں اس شکل میں: Name (City): marks — grade — certificate یا no certificate۔ اپنے دونوں functions استعمال کریں؛ ان کے اصول loop کے اندر دوبارہ نہ لکھیں۔درست نتیجہ: بارہ lines، اور تینوں استثنائی students ایک نظر میں پہچانے جائیں، data کی طرف واپس scroll کیے بغیر۔
-
5وہ نمبر جو سر عمران پوچھتے ہیںloop کے بعد print کریں: کلاس کی average ایک decimal تک، کتنے students نے certificate حاصل کیا، اور سب سے زیادہ نمبر لینے والے کا نام ایک function highest(students) سے جو نام واپس کرے۔درست نتیجہ: تین lines۔ کسی ایک student کے marks بدل کر دوبارہ چلائیں: average اور شاید top scorer بدل جائے، اور کچھ اور نہ ٹوٹے۔
-
6اصول کی تبدیلیacademy attendance کی شرط 75 سے 70 کر دیتی ہے۔ بالکل ایک line edit کر کے تبدیلی کریں، report دوبارہ چلائیں، اور لکھیں کہ کون سی line بدلی اور output میں کیا بدلا۔درست نتیجہ: ایک edit کی ہوئی line۔ اگر ایک سے زیادہ بدلنی پڑیں تو اصول کہیں ایسی جگہ copy ہوا تھا جہاں نہیں ہونا چاہیے تھا — پہلے وہ ٹھیک کریں۔
-
7جان بوجھ کر توڑیںکسی if line سے colon ہٹائیں، چلائیں، error پڑھیں اور ٹھیک کریں۔ پھر ایک quotation mark ہٹائیں، چلائیں، error پڑھیں اور ٹھیک کریں۔ دونوں error messages اپنے notes میں اس line number کے ساتھ copy کریں جس کا ہر ایک نے نام لیا۔درست نتیجہ: notes میں دو error messages، ہر ایک میں line کا نام، ہر ایک ایک منٹ سے کم میں ٹھیک۔
کیا جمع کروانا ہے
آپ کی .py file (یا online editor کا share link)، print ہوئی report paste کی ہوئی، اور پانچ جملے: grade() کیا کرتا ہے، gets_certificate() کیا کرتا ہے، highest() کیا کرتا ہے، task 6 میں آپ نے کون سی ایک line بدلی، اور دونوں errors میں سے کون سا پڑھنا مشکل تھا۔
نمبر کیسے ملیں گے
| معیار | نمبر |
|---|---|
| data ٹھیک بنا، تینوں مشکل records موجود اور نام سے پہچانے گئے | 15 |
| grade() اور gets_certificate() درست ہیں اور ہر اصول بالکل ایک جگہ ہے | 30 |
| report loop functions استعمال کرتے ہوئے ہر student کی ایک واضح line print کرتا ہے | 20 |
| average، certificate کی گنتی اور top scorer درست ہیں | 20 |
| اصول کی تبدیلی ایک line تھی، اور پانچوں جملے واضح ہیں | 15 |
| کل · پاس 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.